(newbie) Is there a way to prevent "name redundancy" in OOP ?
S.Mientki-nospam at mailbox.kun.nl
Sat Jan 6 11:20:54 CET 2007
Steven Bethard wrote:
> Stef Mientki wrote:
>> Not sure I wrote the subject line correct,
>> but the examples might explain if not clear
>> 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".
More information about the Python-list