Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Steven D'Aprano
On Thu, 15 Dec 2011 05:01:21 +, Steven D'Aprano wrote: >> From the Python glossary: >> "method: A function which is defined inside a class body." >> >> That is actually a bit too narrow, as a function can be added to the >> class after it is defined. But the point then is that it is treated

Re: using twisted as a client-server hybrid

2011-12-14 Thread Chris Angelico
On Thu, Dec 15, 2011 at 6:14 PM, Littlefield, Tyler wrote: > Hello all: > I have a quick question--I am working on a project where a system will > connect to me to get commands. The idea is to make the server the "client," > used for dispatching commands, so  I'm trying to find a way that I can se

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Steven D'Aprano
On Thu, 15 Dec 2011 05:15:58 +, MRAB wrote: > On 15/12/2011 05:01, Steven D'Aprano wrote: >> On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote: >> >>> On 12/14/2011 3:01 AM, Steven D'Aprano wrote: On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: > To complement what

using twisted as a client-server hybrid

2011-12-14 Thread Littlefield, Tyler
Hello all: I have a quick question--I am working on a project where a system will connect to me to get commands. The idea is to make the server the "client," used for dispatching commands, so I'm trying to find a way that I can set it up to listen, but poll stdin somehow for input. Is this a

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread MRAB
On 15/12/2011 05:01, Steven D'Aprano wrote: On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote: On 12/14/2011 3:01 AM, Steven D'Aprano wrote: On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: To complement what Eric says below: The with statement is looking for an instance *metho

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2011 18:13:36 -0500, Terry Reedy wrote: > On 12/14/2011 3:01 AM, Steven D'Aprano wrote: >> On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: >> >>> To complement what Eric says below: The with statement is looking for >>> an instance *method*, which by definition, is a function

Re: How to use a color value returned by colorChooser?

2011-12-14 Thread MRAB
On 15/12/2011 02:26, Muddy Coder wrote: Hi Folks, This should be a simple question, but I just can't get an answer from Phython Docs. You see, when we created a widget, and need to tweak the color, we just simply configure it, such as: abutton = Button(root, text='Foo') abutton.config(fg='blue'

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread rusi
On Dec 14, 10:15 pm, Eelco wrote: > 'Kindof' off-topic, but what the hell :). We keep having these debates -- so I wonder how off-topic it is... And so do famous CSists: http://research.microsoft.com/en-us/um/people/gurevich/opera/123.pdf : : > > Again, you are completely mis-representing the

How to use a color value returned by colorChooser?

2011-12-14 Thread Muddy Coder
Hi Folks, This should be a simple question, but I just can't get an answer from Phython Docs. You see, when we created a widget, and need to tweak the color, we just simply configure it, such as: abutton = Button(root, text='Foo') abutton.config(fg='blue') so we can make the Button color in blue

What is this widget? -- again

2011-12-14 Thread Muddy Coder
Hi Folks, Sorry for the unclear question in last post. Well, I am using Tkinter to do GUI, and I just don't know what kind of widget can let me do annotation on an image being displayed. An example is the Paint of Windows: a dotted line box appearing on a image to hold a typed in text. I just can'

PyCharm, .idea, and source control

2011-12-14 Thread alex23
Hey everyone, I've been using PyCharm for the past month and only just hit an issue that I'm hoping someone else may have some experience with resolving. My problem has to do with PyCharm storing project configuration files in its .idea folder inside the project. This is both a mix of project-lev

Re: file data => array(s)

2011-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2011 14:20:40 -0800, Eric wrote: > I'm trying to read some file data into a set of arrays. The file data > is just four columns of numbers, like so: > >1.22.2 3.3 0.5 >0.1 0.21.0 10.1 >... and so on > > I'd like to read this into four arrays, one array f

Re: file data => array(s)

2011-12-14 Thread Eric
On Dec 14, 4:59 pm, Dave Angel wrote: > Note that your code won't work (and mine probably won't either) if one > of the lines has 3 or 5 items.  Or if one of the numbers isn't legal > format for a float.  So you need to think about error checking, or > decide whether a partial result is important

Re: What is this widget?

2011-12-14 Thread Terry Reedy
On 12/14/2011 1:47 PM, Muddy Coder wrote: Hi Folks, I am trying to write letters on a photo that is opened in a canvas. So I think I must need a widget to contain the letters I will type in. I tried to use a Label, it worked. But, a Label covered part of the photo underneath, so I can't use it.

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Terry Reedy
On 12/14/2011 3:01 AM, Steven D'Aprano wrote: On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: To complement what Eric says below: The with statement is looking for an instance *method*, which by definition, is a function attribute of a *class* (the class of the context manager) that take

Re: file data => array(s)

2011-12-14 Thread Dave Angel
On 12/14/2011 05:20 PM, Eric wrote: I'm trying to read some file data into a set of arrays. The file data is just four columns of numbers, like so: 1.22.2 3.3 0.5 0.1 0.21.0 10.1 ... and so on I'd like to read this into four arrays, one array for each column. Alternat

file data => array(s)

2011-12-14 Thread Eric
I'm trying to read some file data into a set of arrays. The file data is just four columns of numbers, like so: 1.22.2 3.3 0.5 0.1 0.21.0 10.1 ... and so on I'd like to read this into four arrays, one array for each column. Alternatively, I guess something like this is oka

Re: replacing timestamps in file [newbie]

2011-12-14 Thread Chris Angelico
On Thu, Dec 15, 2011 at 7:32 AM, nukeymusic wrote: > I have a file which has the data in the following format: > Dec-13-09:46:45 21.4 +4.76442190E-01 8.135530E-06 1.553691E+00 > > the first field is a timestamp, I'd like to replace it with the time > in seconds starting from the first one like thi

Re: replacing timestamps in file [newbie]

2011-12-14 Thread Miki Tebeka
You can either work with datetime module (see datetime.datetime.strptime) or with the time module (see time.strptime and time.mktime) -- http://mail.python.org/mailman/listinfo/python-list

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Terry Reedy
On 12/14/2011 5:09 AM, Eelco wrote: Arguably, the most elegant thing to do is to define integer division and remainder as a single operation; It actually is, as quotient and remainder are calculated together. The microprocessors I know of expose this (as does Python). 'a divmod b' puts the q

replacing timestamps in file [newbie]

2011-12-14 Thread nukeymusic
I have a file which has the data in the following format: Dec-13-09:46:45 21.4 +4.76442190E-01 8.135530E-06 1.553691E+00 Dec-13-09:47:12 21.4 +4.76439120E-01 8.135839E-06 1.553726E+00 Dec-13-09:47:39 21.4 +4.76427260E-01 8.136261E-06 1.553853E+00 . . the first field is a timestamp, I'd like to repl

Re: What is this widget?

2011-12-14 Thread Dave Angel
On 12/14/2011 01:47 PM, Muddy Coder wrote: Hi Folks, I am trying to write letters on a photo that is opened in a canvas. So I think I must need a widget to contain the letters I will type in. I tried to use a Label, it worked. But, a Label covered part of the photo underneath, so I can't use it.

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Eric Snow
On Wed, Dec 14, 2011 at 12:14 PM, Lie Ryan wrote: > On 12/15/2011 03:56 AM, Eric Snow wrote: >> >> On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow >>  wrote: >> >> If you want to be more dynamic about it you can do it, but it involves >> black magic.  Chances are really good that being explicit throug

What is this widget?

2011-12-14 Thread Muddy Coder
Hi Folks, I am trying to write letters on a photo that is opened in a canvas. So I think I must need a widget to contain the letters I will type in. I tried to use a Label, it worked. But, a Label covered part of the photo underneath, so I can't use it. I saw some software did such a thing nicely:

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Lie Ryan
On 12/15/2011 03:56 AM, Eric Snow wrote: On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow wrote: If you want to be more dynamic about it you can do it, but it involves black magic. Chances are really good that being explicit through your class definition is the right approach. Note that the black

Re: How to install Python on Debian GNU/Linux (Python-2.7.2.tar.bz2)

2011-12-14 Thread Anssi Saari
Christian Heimes writes: >> Mea culpa, forgot that. Yes, use altinstall. Although it's probably >> not a problem to replace 2.6.6 with 2.7.2 - I doubt that'll break many >> things. > > Except that all 3rd party extensions and packages are missing if you > install Python manually. True, they woul

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Steve Howell
On Dec 14, 12:01 am, Steven D'Aprano wrote: > [...] > > So the normal lookup rules that apply to data attributes, namely > instance, then class, then superclasses, also applies to methods in > Python. In languages that don't allow that sort of thing, like Java, you > need to use convoluted design

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Eelco
'Kindof' off-topic, but what the hell :). On Dec 14, 5:13 pm, Arnaud Delobelle wrote: > On 14 December 2011 12:33, Eelco wrote: > > On 14 dec, 12:55, Arnaud Delobelle wrote: > >> On 14 December 2011 07:49, Eelco wrote: > >> > On Dec 14, 4:18 am, Steven D'Aprano >> > +comp.lang.pyt...@pearwood

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Joshua Landau wrote: [snip] Using currentLogger is just padding, in my opinion. *Every *value is "current". Not always. I try to keep names on the same object because that object is supposed to be named that way. I can change one of the object attribute, but the object named that way keep bein

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Eric Snow
On Tue, Dec 13, 2011 at 11:05 PM, Eric Snow wrote: > On Tue, Dec 13, 2011 at 10:42 PM, Steve Howell wrote: >> I'm using Python 3.2.2, and the following program gives me an error >> that I don't understand: >> >> class Foo: >>  pass >> >> foo = Foo() >> foo.name = "Steve" >> >> def add_goodbye_fun

Re: Overriding a global

2011-12-14 Thread Joshua Landau
On 14 December 2011 10:14, Jean-Michel Pichavant wrote: > Joshua Landau wrote: > > On 13 December 2011 13:30, Jean-Michel Pichavant > > jeanmic...@sequans.com**>> wrote: >> >>writing >> >>x = 1 >> >>def spam(): >> x = 2 >> >>is in general a bad idea. That was my point. >> >>

Re: Property Abuse

2011-12-14 Thread Jean-Michel Pichavant
Ian Kelly wrote: On Wed, Dec 14, 2011 at 1:28 AM, Felipe O wrote: Hi All, I was wondering what everyone's thought process was regarding properties. Lately I find I've been binging on them and have classes with > 10 properties. While pylint doesn't complain (yet), it tends to be picky about k

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread 88888 Dihedral
On Thursday, December 15, 2011 12:08:32 AM UTC+8, 8 Dihedral wrote: > On Wednesday, December 14, 2011 4:01:24 PM UTC+8, Steven D'Aprano wrote: > > On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: > > > > > To complement what Eric says below: The with statement is looking for an > > > ins

Re: Property Abuse

2011-12-14 Thread Ian Kelly
On Wed, Dec 14, 2011 at 1:28 AM, Felipe O wrote: > Hi All, > I was wondering what everyone's thought process was regarding properties. > Lately I find I've been binging on them and have classes with > 10 > properties. While pylint doesn't complain (yet), it tends to be picky about > keeping instan

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread 88888 Dihedral
On Wednesday, December 14, 2011 4:01:24 PM UTC+8, Steven D'Aprano wrote: > On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: > > > To complement what Eric says below: The with statement is looking for an > > instance *method*, which by definition, is a function attribute of a > > *class* (the

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Arnaud Delobelle
On 14 December 2011 12:33, Eelco wrote: > On 14 dec, 12:55, Arnaud Delobelle wrote: >> On 14 December 2011 07:49, Eelco wrote: >> > On Dec 14, 4:18 am, Steven D'Aprano > > +comp.lang.pyt...@pearwood.info> wrote: >> >> > They might not be willing to define it, but as soon as we programmers >> >>

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Ian Kelly
On Wed, Dec 14, 2011 at 6:29 AM, Eelco wrote: > On Dec 14, 1:38 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Wed, 14 Dec 2011 02:09:32 -0800, Eelco wrote: >> > Arguably, the most elegant thing to do is to define integer division and >> > remainder as a single operation; which

Re: text to html

2011-12-14 Thread James Mills
On Dec 14, 3:30 am, Pedro Henrique Guedes Souto wrote: > On Tue, Dec 13, 2011 at 3:22 PM, prakash jp wrote: > > Want to publish a log file as a web page, is there a parser to retain the > > format of the text as is and then convert to html. Please provide the > > relevant pointers Hey Pedro,

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Chris Angelico
On Thu, Dec 15, 2011 at 12:29 AM, Eelco wrote: > On Dec 14, 1:38 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> That would be: >> >> >>> divmod(17, 5) >> >> (3, 2) > > Cool; if only it were in the math module id be totally happy. That's easily solved. import math math.divmod=div

Re: Regexp : repeated group identification

2011-12-14 Thread Vlastimil Brom
2011/12/14 candide : ... > > Thanks for the reference and the example. I didn't know of this > reimplementation, hoping it offers the Aho-Corasick algorithm allowing > multiple keys search. > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I am not sure about the underlying algorithm

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Wed, 14 Dec 2011 13:05:19 +0100, Jean-Michel Pichavant wrote: Bad ideas : i = 5 def spam(): for i,v in enumerate([1,2,3,4]): for i,v in enumerate(['a','b', 'c']): print i, v print i,v # bad surprise The bad surprise happens because you are u

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Eelco
On Dec 14, 1:38 pm, Steven D'Aprano wrote: > On Wed, 14 Dec 2011 02:09:32 -0800, Eelco wrote: > > Arguably, the most elegant thing to do is to define integer division and > > remainder as a single operation; which is not only the logical thing to > > do mathematically, but might work really well p

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Wed, 14 Dec 2011 10:56:02 +0200, Jussi Piitulainen wrote: > > I'm not misunderstanding any argument. There was no > > argument. There was a blanket pronouncement that _in mathematics_ > > mod is not a binary operator. I should learn to challenge such > > pronouncements

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Jussi Piitulainen
rusi writes: > On Dec 14, 1:56 pm, Jussi Piitulainen > wrote: > > > > Is someone saying that _division_ is not defined because -42 div -5 is > > somehow both 9 and 8? Hm, yes, I see that someone might. The two > > operations, div and rem, need to be defined together. > ---

Re: Regexp : repeated group identification

2011-12-14 Thread candide
Le 14/12/2011 12:34, Vlastimil Brom a écrit : "If a group is contained in a part of the pattern that matched multiple times, the last match is returned." I missed this point, your answer matches my question ;) thanks. If you need to work with the content captured in the repeated group, you

Re: Overriding a global

2011-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2011 13:05:19 +0100, Jean-Michel Pichavant wrote: > Bad ideas : > > i = 5 > > def spam(): > for i,v in enumerate([1,2,3,4]): > for i,v in enumerate(['a','b', 'c']): > print i, v > print i,v # bad surprise The bad surprise happens because you are using the same nam

Re: [GENERAL] Philosophical question

2011-12-14 Thread Chris Angelico
On Wed, Dec 14, 2011 at 11:32 PM, Andreas wrote: > Hi, > > I asked elsewhere about the best way to store db credentials within a > user-session of a web-app. > > It appeared that it was for everybody but me evident that instead of heaving > a db-role+passwd for every user of an application it was

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Eelco
On 14 dec, 13:22, Jussi Piitulainen wrote: > > > Is someone saying that _division_ is not defined because -42 div > > > -5 is somehow both 9 and 8? Hm, yes, I see that someone might. The > > > two operations, div and rem, need to be defined together. > > > > (There is no way to make remainder a bi

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2011 02:09:32 -0800, Eelco wrote: > Arguably, the most elegant thing to do is to define integer division and > remainder as a single operation; which is not only the logical thing to > do mathematically, but might work really well programmatically too. > > The semantics of python d

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Eelco
On 14 dec, 12:55, Arnaud Delobelle wrote: > On 14 December 2011 07:49, Eelco wrote: > > On Dec 14, 4:18 am, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote: > >> > They might not be willing to define it, but as soon as we programmers > >> > do, well, we did. > > >> > Having studied the

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2011 10:56:02 +0200, Jussi Piitulainen wrote: > Steven D'Aprano writes: >> On Mon, 12 Dec 2011 09:29:11 -0800, Eelco wrote: >> >> [quoting Jussi Piitulainen ] >> >> They recognize modular arithmetic but for some reason insist that >> >> there is no such _binary operation_. But as I

Re: automate commands to an .exe console program through python

2011-12-14 Thread Juan Perez
Hi, Well if I can remmeber since last time I did something similar in C, it was close stdin channel in the open devices table (I don't know if it is the correct name in english, I learnt it in spanish) and put a pipe on it and then create a fork, parent it comunicates to the child through the pipe

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Jussi Piitulainen
Eelco writes: > On 14 dec, 09:56, Jussi Piitulainen wrote: > > But I think the argument "there are several such functions, > > therefore, _in mathematics_, there is no such function" is its own > > caricature. > > Indeed. Obtaining a well defined function is just a matter of > picking a convention

Re: Overriding a global

2011-12-14 Thread Chris Angelico
On Wed, Dec 14, 2011 at 11:05 PM, Jean-Michel Pichavant wrote: > Chris Angelico wrote: >> >> So... it's a bad idea for me to use 'i' many times in my code, with >> the same name having different meanings in different places? In >> languages with infinitely-nesting scopes... > Bad ideas : > > i =

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Chris Angelico wrote: On Wed, Dec 14, 2011 at 9:14 PM, Jean-Michel Pichavant wrote: The problem makes little sense when using names like x or func1. Besides namespace issues, naming 2 *different objects* with the same meaningful name is usually a bad idea and points the fact that your names

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Arnaud Delobelle
On 14 December 2011 07:49, Eelco wrote: > On Dec 14, 4:18 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> > They might not be willing to define it, but as soon as we programmers >> > do, well, we did. >> >> > Having studied the contemporary philosophy of mathematics, their concern

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Chris Angelico
On Wed, Dec 14, 2011 at 10:47 PM, rusi wrote: > `quot` is integer division truncated toward zero, while the result of > `div` is truncated toward negative infinity. All these problems just because of negative numbers. They ought never to have been invented. At least nobody rounds toward positive

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread rusi
On Dec 14, 1:56 pm, Jussi Piitulainen wrote: > > Is someone saying that _division_ is not defined because -42 div -5 is > somehow both 9 and 8? Hm, yes, I see that someone might. The two > operations, div and rem, need to be defined together. - Haskell defines a quot-re

Re: Regexp : repeated group identification

2011-12-14 Thread Vlastimil Brom
2011/12/14 candide : > Consider the following code > > # > import re > > z=re.match('(Spam\d)+', 'Spam4Spam2Spam7Spam8') > print z.group(0) > print z.group(1) > # > > outputting : > > > Spam4Spam2Spam7Spam8 > Spa

Question (PDE solvers in Python)

2011-12-14 Thread narges javaheri
Hello there, Based on your experiences, what's the best (the most reliable) package for solving a system of nonlinear coupled PDEs (partial differential equations) in 3D using Python, preferably by FEM (finite element method)? Regards, Narges -- http://mail.python.org/mailman/listinfo/python-lis

Regexp : repeated group identification

2011-12-14 Thread candide
Consider the following code # import re z=re.match('(Spam\d)+', 'Spam4Spam2Spam7Spam8') print z.group(0) print z.group(1) # outputting : Spam4Spam2Spam7Spam8 Spam8 The '(Spam\d)

Re: Overriding a global

2011-12-14 Thread Chris Angelico
On Wed, Dec 14, 2011 at 9:14 PM, Jean-Michel Pichavant wrote: > The problem makes little sense when using names like x or func1. Besides > namespace issues, naming 2 *different objects* with the same meaningful name > is usually a bad idea and points the fact that your names are no that > meaningf

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Eelco
On 14 dec, 09:56, Jussi Piitulainen wrote: > Steven D'Aprano writes: > > On Mon, 12 Dec 2011 09:29:11 -0800, Eelco wrote: > > > [quoting Jussi Piitulainen ] > > >> They recognize modular arithmetic but for some reason insist that > > >> there is no such _binary operation_. But as I said, I don't >

Re: Overriding a global

2011-12-14 Thread Jean-Michel Pichavant
Joshua Landau wrote: On 13 December 2011 13:30, Jean-Michel Pichavant mailto:jeanmic...@sequans.com>> wrote: writing x = 1 def spam(): x = 2 is in general a bad idea. That was my point. Why? I have a few (probably wrong) guesses. Because you expect it to be the same

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Peter Otten
Steve Howell wrote: > I'm using Python 3.2.2, and the following program gives me an error > that I don't understand: > > class Foo: > pass > > foo = Foo() > foo.name = "Steve" > > def add_goodbye_function(obj): > def goodbye(): > print("goodbye " + obj.name) > obj.goodbye = goodbye >

Re: % is not an operator

2011-12-14 Thread Paul Rudin
Steven D'Aprano writes: > The existence of two potential answers for the remainder is certainly > correct, but the conclusion that remainder is not a binary operation > doesn't follow. It is a binary relation. This depends on your definition of "operation". Normally an operation is a function

Re: xml, minidom, ElementTree

2011-12-14 Thread Paul Rudin
Ethan Furman writes: > In the near future I will need to parse and rewrite parts of a xml files > created by a third-party program (PrintShopMail, for the curious). > It contains both binary and textual data. > > There has been some strong debate about the merits of minidom vs > ElementTree. > >

Re: boolean from a function

2011-12-14 Thread Andrea Crotti
On 12/13/2011 11:37 PM, Steven D'Aprano wrote: x is a global? Poor design. But in any case, instead of an explicit if...else block, the canonical way to convert an arbitrary object to True/ False is with bool: def func_bool(): return bool(x) But you don't need it. See below. No no it

Re: Verbose and flexible args and kwargs syntax

2011-12-14 Thread Jussi Piitulainen
Nick Dokos writes: > Jussi Piitulainen wrote: > > They recognize modular arithmetic but for some reason insist that > > there is no such _binary operation_. But as I said, I don't > > understand their concern. (Except the related concern about some > > programming languages, not Python, where the r

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Mon, 12 Dec 2011 09:29:11 -0800, Eelco wrote: > > [quoting Jussi Piitulainen ] > >> They recognize modular arithmetic but for some reason insist that > >> there is no such _binary operation_. But as I said, I don't > >> understand their concern. (Except the related con

Property Abuse

2011-12-14 Thread Felipe O
Hi All, I was wondering what everyone's thought process was regarding properties. Lately I find I've been binging on them and have classes with > 10 properties. While pylint doesn't complain (yet), it tends to be picky about keeping instance attribute counts low, so I figure there's something again

Re: % is not an operator [was Re: Verbose and flexible args and kwargs syntax]

2011-12-14 Thread Eelco
On Dec 14, 4:18 am, Steven D'Aprano wrote: > > They might not be willing to define it, but as soon as we programmers > > do, well, we did. > > > Having studied the contemporary philosophy of mathematics, their concern > > is probably that in their minds, mathematics is whatever some dead guy > > s

Re: AttributeError in "with" statement (3.2.2)

2011-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2011 01:29:13 -0500, Terry Reedy wrote: > To complement what Eric says below: The with statement is looking for an > instance *method*, which by definition, is a function attribute of a > *class* (the class of the context manager) that takes an instance of the > class as its first p