On Jul 14, 6:27 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 13 Jul 2007 13:24:57 -0300, bvdp <[EMAIL PROTECTED]> escribió: > > > > > > >> Seehttp://effbot.org/zone/import-confusion.htm > >> Try to move the circular references later in the code (maybe inside a > >> function, when it is required), or much better, refactor it so there is > >> no > >> circularity. > > >> -- > >> Gabriel Genellina > > > Yes, thanks. I'd read that page before posting. Helpful. > > > But, I still don't understand how python can access a function in a > > file I have NOT included. In this case, to get things to work, I DO > > NOT "import MMA.grooves" but later in the module I access a function > > with "xx=MMA.grooves.somefunc()" and it finds the function, and works > > just fine. It shouldn't work. > > That depends a bit on what is "MMA" and what is "grooves". > MMA.grooves means "look for an attribute named grooves inside MMA". If MMA > is a module, and MMA.grooves is a class/function defined inside the > module, you don't need to import it before using it.
I am a bit confused: I think the above should be: if MMA.grooves in a class/function defined inside the module MMA, you don't need to import the class/function before using it, but only import the module MMA. Am I wrong? tia, ./alex -- .w( the_mindstorm )p. > But if MMA is a package, and MMA.grooves is a module inside that package, > you need to import it first (unless MMA/__init__.py does that already) > > > I have tried to delay the import, and that does work. But, from a > > stylistic view I really to like to have all my imports at the top of > > the module. Maybe some old assembler/C habits on my part. > > Sure, it's considered good style. > > -- > Gabriel Genellina
-- http://mail.python.org/mailman/listinfo/python-list