"Terry Reedy" <[EMAIL PROTECTED]> wrote:

> 
> "John Bokma" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>>> def foo():
>>>     import bar
>>>     bar.printStuff()
>> I am new to Python so this might be a weird question, but it there a
>> reason why you import bar inside foo?
> 
> Two possible reasons:
> 1) delay import until actually needed, if ever.
> 2) put 'bar' into the function local namespace instead of the module
> global namespace

OK clear and thanks. I was guessing the later, and the first one I 
overlooked (Perl works different, you have to do the delay yourself).

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to