(newbie) Is there a way to prevent "name redundancy" in OOP ?
Stef Mientki
S.Mientki-nospam at mailbox.kun.nl
Sat Jan 6 05:20:54 EST 2007
Steven Bethard wrote:
> Stef Mientki wrote:
>> Not sure I wrote the subject line correct,
>> but the examples might explain if not clear
> [snip]
>> class pin2:
>> def __init__ (self, naam):
>> self.Name = naam
>>
>> aap2 = pin2('aap2') # seems completely redundant to me.
>> print aap2.Name
>
> You can use class statements to create your instances with some
> metaclass trickery. Unlike normal assignments, class statements get
> access to the name being assigned. So you could write your class like::
thank you all guys,
this gives me a lot to study,
for the moment I'm satisfied with the fact that it "is possible".
cheers,
Stef Mientki
More information about the Python-list
mailing list