(newbie) Is there a way to prevent "name redundancy" in OOP ?

Jorge Vargas jorge.vargas at gmail.com
Fri Jan 5 22:13:06 CET 2007


On 1/5/07, Stef Mientki <S.Mientki-nospam at mailbox.kun.nl> wrote:

if I undestand correctly this is what you want

>>> class pin3:
...     def __init__(self,name):
...             self.Name = name
...     def __str__(self):
...             return self.Name
...
>>> pin3()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __init__() takes exactly 2 arguments (1 given)
>>> pin3('aaa')
<__main__.pin3 instance at 0xb7dc948c>
>>> print pin3('aaa')
aaa



More information about the Python-list mailing list