Importing modules

Marco Mariani marco at sferacarta.com
Wed Jan 21 11:29:24 EST 2009


Mudcat wrote:

> This is something I've wondered about for a while. I know that
> theoretically Python is supposed to auto-recognize duplicate imports;
> however I've run into problems in the past if I didn't arrange the
> imports in a certain way across multiple files.

I think you've probably had issues with circular imports (i.e. mutual 
dependencies), unless you can precisely remember what you were doing and 
what went wrong.

> As a result, I worry about conflicts that arise because something has been imported twice.
> So...I'm not sure if Python *always* gets this correct.

It doesn't import twice, and never did.

> Also, I understand what you're saying about the organization of files
> based on modules and maybe regrouping based on use. However I like the
> organization of my files to be a grouping of logical components in my
> application.

I can make up three or four different logical groupings in my 
applications... so what is 'logical' could not be the same for everyone, 
or from every point of view.




More information about the Python-list mailing list