Killin' Newbie question
Gregoire Welraeds
greg at perceval.be
Mon Feb 28 11:36:44 EST 2000
More information about the Python-list mailing list
Mon Feb 28 11:36:44 EST 2000
- Previous message (by thread): Killin' Newbie question
- Next message (by thread): Killin' Newbie question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In reply to the message of Ken Seehof sent on Feb 28 (see below) : thanks for all reply. until-next-"this-looks-like-another-newbie"-question'ly yours :) -- Life is not fair But the root password helps -- Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Mon, 28 Feb 2000, Ken Seehof wrote: > Date: Mon, 28 Feb 2000 09:07:47 -0800 > From: Ken Seehof <kens at sightreader.com> > To: python-list at python.org > Newsgroups: comp.lang.python > Subject: Re: Killin' Newbie question > > Gregoire Welraeds wrote: > > > 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__() > > ---- > > > > Right ? > > The following should be allowed ? > > > > class huh(): > > def __init__(self): > > [some initialisation] > > > > def ReInit(self): > > self.__init__() > > > > ough= huh() > > [some code] > > ough.ReInit() > > > > Do I have to rewrite the __init__ function in the ReInit() or the call to > > the init() function inside the ReInit is enough ? > > Isn't there a better way to do this kind of job, i mean in a OOP point of > > view. > > Since the previous reply answers your first question, I'll talk aboutprogramming > style. I would tend to write a ReInit function since > __init__ really means "called when you create the object". However, > there is nothing illegal about calling __init__ directly. > > class huh: > def __init__(self): > # some one-time initialization code > print "spammity" > self.ReInit() > > def ReInit(self): > # some code > print "spam" > > >>> h = huh() > spammity > spam > >>> h.ReInit() > spam > > The only time __init__ is usually called is from a derived object: > > class what(huh): > def __init__(self): > huh.__init__(self) > # more initialization for what > > > Other little question, what about the following (regarding another remark > > posted before) : > > > > def __init__(this): > > Legal, but don't do that. People will think you are a C programmer :-) Ack! > > > -- > > Life is not fair > > But the root password helps > > -- > > > > Gregoire Welraeds > > greg at perceval.be > > Perceval Development team > > ------------------------------------------------------------------------------- > > Perceval Technologies sa/nv Tel: +32-2-6409194 > > Rue Tenbosch, 9 Fax: +32-2-6403154 > > B-1000 Brussels general information: info at perceval.net > > BELGIUM technical information: helpdesk at perceval.net > > URL: http://www.perceval.be/ > > ------------------------------------------------------------------------------- > > > > -- > http://www.python.org/mailman/listinfo/python-list > >
- Previous message (by thread): Killin' Newbie question
- Next message (by thread): Killin' Newbie question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list