undesired traceback

Roland Mas mas at echo.fr
Sun Aug 13 01:02:32 EDT 2000


etoffi at softhome.net (2000-08-13 00:45:42 -0400) :

> why is this code giving me a traceback?
> (TypeError: No arguments expected)

Because the __init__() function is called with an argument that it
does not expect.  That argument is often named self, for it is the
newly_created object.

> class Foo:
> 	def __init__():
> 		pass
> 
> f = Foo()

>>> class Foo:
...     def __init__ (self):
...         self.attribute1 = "value1"
... 
>>> f = Foo ()
>>> f.attribute1
'value1'
>>> 
-- 
Roland Mas

C r  ' s  d   a  u    e   e    ll r   a  u i r .  
  -- Signatures à collectionner, série n°1, partie 1/3.



More information about the Python-list mailing list