Module imports during object instantiation

Ritesh Raj Sarraf rrs at researchut.com
Thu Aug 16 13:25:26 EDT 2007


Steve Holden wrote:

> Ritesh Raj Sarraf wrote:
>> On Aug 16, 12:16 am, Ritesh Raj Sarraf <r... at researchut.com> wrote:
>>> On Aug 15, 11:42 pm, Neil Cerutti <horp... at yahoo.com> wrote:
>>>
> [...]
>> Oops!!! Looks like I completely missed this. It _did_ print the error
>> message.
>> Apologies to all for not keeping a close eye on the error message.
>> 
> Quite. It was obvious to many readers that you were fooling yourself
> with a false hypothesis. The probability of something so fundamental
> being wrong is vanishingly small.
> 

Yes, and now I realize how I would have got into the stupid assumption that
imports were never executed in a class' __init__() was because:

* I defined an import within a class' __init__()
* It used to get executed.
* Then I used to make an assumption that calling it from one of the methods
would work. But instead the module was never in the Namespace. And that led
me to the mis-understanding that the import never got executed. What a fool
am I.


I think people gave a good reason when they mentioned about top-level
imports. I would move ahead with keeping things simple.

Thanks to all for your time and patience on this thread (At least, no one is
yelling at me ;-)


Ritesh
-- 
If possible, Please CC me when replying. I'm not subscribed to the list.




More information about the Python-list mailing list