On Jan 28, 11:32 pm, "Gabriel Genellina"
wrote:
> En Wed, 28 Jan 2009 16:05:39 -0200, 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-i
En Wed, 28 Jan 2009 16:05:39 -0200, 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? Just
for the record,
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 _createGetter(se
Mark Wooding wrote:
> Steve Holden 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
Steve Holden 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 trouble rec
On 26 Jan., 15:13, Steve Holden 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 intended t
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 r
Michael Torrie 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 between binding and
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 clos
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 ar
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 ex
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):
>
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 prope
14 matches
Mail list logo