hehe, yeah, after sending my email I realized that it was obvious, but
the true is I came up with this problem in a more complex situation
involving lot's of imports and so on.. so the question: wtf is going
on?? came up to me at this time :P
> If you want to capture the value of name at the time when get_name() is
> defined you have several options:
>
> - The default argument trick:
>
> def get_name(self, name=name):
> return name
>
> - A closure:
>
> def make_get_name(name):
> def get_name(self):
> return name
> return get_name
> A.name = property(make_get_name(name))
>
> - functools.partial()
>
> def get_name(self, name):
> return name
> A.name = property(partial(get_name, name=name))
Wow Peter, I was expecting one solution and you give me 3 amazing
solutions!! :) Thanks a lot!
btw I always wondered for what functools.partial can be useful, now I
know an example :)