Killin' Newbie question
Justin Sheehy
dworkin at ccs.neu.edu
Mon Feb 28 10:03:28 EST 2000
Gregoire Welraeds <greg at perceval.be> writes:
> I can't access the __init__ method outside of the object, so the
> following is disallowed :
> ----
> class huh():
> def __init(self):
> [some initialisation]
>
> ough= huh()
>
> [some code]
>
> ough.__init__()
> ----
If you fix the two minor errors in your code, the above works fine:
>>> class huh:
... def __init__(self):
... print 'spam'
...
>>> ough = huh()
spam
>>> ough.__init__()
spam
> Other little question, what about the following (regarding another remark
> posted before) :
>
> def __init__(this):
Sure, that's fine. There is nothing special about 'self', it is
merely a convention. The instance is passed as the first argument to
methods; the position matters, not the name.
-Justin
More information about the Python-list
mailing list