- E04 - Leadership! Google, Guido van Rossum, PSF

Ilias Lazaridis ilias at lazaridis.com
Wed Jan 4 11:55:03 EST 2006


Alex Martelli wrote:
> Ilias Lazaridis <ilias at lazaridis.com> wrote:
> 
>>>>  attr_accessor :name, :age
> 
>>I would need this python "attr_accessor", to showcase that python is 
>>capable to do it (even if the usage seems irrational/redundant).
[...] - (comments, code "outside the body")

> def make_silly_attr_accessor(name):
>    def get(self, name): return getattr(self, '_'+name)
>    def set(self, name, value): return setattr(self, '_'+name, value)
>    return property(get, set)
> 
> to be used as in:
> 
> class Talker(object):
>   age = make_silly_attr_accessor('age')
>   name = make_silly_attr_accessor('name')
> 
> Finally, you could choose to use a decorator syntax instead:
[...] - (decorator example, comments)

ok, this one is nice.

-

[/REQUOTE]
>>>>> instance and introspecting on it.  Would such instantiation be OK here?
>>>>
>>>> If I understand you right, it would be ok.
>>>>
>>>> The requirements are given by the template:
>>>>
>>>> john.sayYourClassDefinition()
>>>>
>>>> "john" is instantiated, when asked for his class definition.
>>>
>>> OK, I'll look into that in my copious spare time (unless somebody else
>>> does the work first;-).
>> 
>> would be very nice! 
[/REQUOTE]

Just for completeness:

I some reader has a compact solution, please post it or sent it via 
email / form.

-

Mr. Martelli,

Thank you very much !!!

.

-- 
http://lazaridis.com



More information about the Python-list mailing list