On Jan 28, 11:32 pm, Gabriel Genellina gagsl-...@yahoo.com.ar
wrote:
En Wed, 28 Jan 2009 16:05:39 -0200, coutinhoti...@gmail.com
coutinhoti...@gmail.com escribió:
I had the same problem myself.
Mark's detailed explanation really helped me understand.
I ended up doing something
Hi!
I had the same problem myself.
Mark's detailed explanation really helped me understand.
I ended up doing something like:
class A:
def __init__(self):
names = 'n1', 'n2'
for n in names:
setattr(self, get%s % n, self._createGetter(n))
def
En Wed, 28 Jan 2009 16:05:39 -0200, coutinhoti...@gmail.com
coutinhoti...@gmail.com escribió:
I had the same problem myself.
Mark's detailed explanation really helped me understand.
I ended up doing something like:
The code doesn't work as-is, could you please post a working version?
Michael Torrie torr...@gmail.com writes:
Basically, don't use a lambda. Create a real, local closure with a
nested def block. That way the closure is created every time the
parent function is called.
Nope. I explained the real problem quite clearly, and it's to do with
the difference
Mark Wooding wrote:
unine...@gmail.com writes:
[...]
* Assignment stores a new (reference to a) value in the variable.
* Binding modifies the mapping between names and variables.
I realise I have omitted what was doubtless intended to be explanatory
detail, but I am having trouble
On 26 Jan., 15:13, Steve Holden st...@holdenweb.com wrote:
Mark Wooding wrote:
unine...@gmail.com writes:
[...]
* Assignment stores a new (reference to a) value in the variable.
* Binding modifies the mapping between names and variables.
I realise I have omitted what was doubtless
Steve Holden st...@holdenweb.com writes:
Mark Wooding wrote:
* Assignment stores a new (reference to a) value in the variable.
* Binding modifies the mapping between names and variables.
I realise I have omitted what was doubtless intended to be explanatory
detail, but I am having
Mark Wooding wrote:
Steve Holden st...@holdenweb.com writes:
Mark Wooding wrote:
* Assignment stores a new (reference to a) value in the variable.
* Binding modifies the mapping between names and variables.
I realise I have omitted what was doubtless intended to be explanatory
On 23 Jan., 13:28, unine...@gmail.com wrote:
Hi,
I want to add some properties dynamically to a class, and then add the
corresponding getter methods. Something resulting in this:
class Person:
def Getname(self):
return self.__name
def Getage(self):
return
unine...@gmail.com wrote:
The attributes are right, but the getter are not working. The problem
is that the lambda function always execute the last parameter passed
for all instances of the methods. How could it be done the right way?
Basically, don't use a lambda. Create a real, local
Hi,
I want to add some properties dynamically to a class, and then add the
corresponding getter methods. Something resulting in this:
class Person:
def Getname(self):
return self.__name
def Getage(self):
return self.__age
I've implemented the next code, creating the
On Fri, 23 Jan 2009 04:28:33 -0800, unineuro wrote:
Hi,
I want to add some properties dynamically to a class, and then add the
corresponding getter methods. Something resulting in this:
class Person:
def Getname(self):
return self.__name
def Getage(self):
unine...@gmail.com wrote:
class Person:
def __init__(self):
for prop in props:
setattr(self, __ + prop[0], prop[1])
setattr(Person, Get + prop[0], lambda self: getattr
(self, __ + prop[0]))
I've had a similar problem here and here is best how I can explain
unine...@gmail.com writes:
class Person:
def __init__(self):
for prop in props:
setattr(self, __ + prop[0], prop[1])
setattr(Person, Get + prop[0], lambda self: getattr
(self, __ + prop[0]))
[...]
The attributes are right, but the getter are not
14 matches
Mail list logo