Module imports during object instantiation

Neil Cerutti horpner at yahoo.com
Tue Aug 14 10:50:08 EDT 2007


On 2007-08-14, Ritesh Raj Sarraf <rrs at researchut.com> wrote:
> Neil Cerutti wrote:
>
>> If you want an import inside an __init__ to run, you must call
>> the __init__ function that contains it.
>
> Doesn't __init__ get called automatically ?

It gets called automatically when you construct an instance of
the class in which it's defined.

> I thought __init__ was required to be called explicitly only
> when you were doing inheritance and wanted to pass separate
> values to the base class.

You don't have to call it explicitly to get it to run.

-- 
Neil Cerutti
Customers who consider our waitresses uncivil ought to see the manager --sign
at New York restaurant



More information about the Python-list mailing list