Re: package import dangers

2009-10-09 Thread Ethan Furman
Thanks to all for the answers! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: package import dangers

2009-10-06 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 06 Oct 2009 21:44:35 -0400, Dave Angel wrote: I'm surprised to see you missed this. A module doesn't generally import itself, but it's an easy mistake for a circular dependency to develop among modules. Circular imports are always a difficulty. That has

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 21:44:35 -0400, Dave Angel wrote: > I'm surprised to see you missed this. A module doesn't generally import > itself, but it's an easy mistake for a circular dependency to develop > among modules. Circular imports are always a difficulty. That has nothing to do with making m

Re: package import dangers

2009-10-06 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: The most common problem is that a file is used as module and as executable at the same time. Like this: --- test.py --- class Foo(object): pass if __name__ == "__main__": import test assert Foo

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 17:01:41 -0700, Carl Banks wrote: >> Why would a module need to import itself? Surely that's a very rare >> occurrence -- I think I've used it twice, in 12 years or so. I don't >> see why you need to disparage the idea of combining modules and scripts >> in the one file because

Re: package import dangers

2009-10-06 Thread Carl Banks
On Oct 6, 3:56 pm, Steven D'Aprano wrote: > On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: > > The most common problem is that a file is used as module and as > > executable at the same time. > > > Like this: > > > --- test.py --- > > > class Foo(object): > >     pass > > > if __name_

Re: package import dangers

2009-10-06 Thread Steven D'Aprano
On Tue, 06 Oct 2009 18:42:16 +0200, Diez B. Roggisch wrote: > The most common problem is that a file is used as module and as > executable at the same time. > > Like this: > > --- test.py --- > > class Foo(object): > pass > > > if __name__ == "__main__": >import test >assert Foo i

Re: package import dangers

2009-10-06 Thread Diez B. Roggisch
Ethan Furman wrote: > Greetings! > > I'm working on a package with multiple modules (and possibly packages), > and I would like to do it correctly. :) > > I have read of references to possible issues regarding a module being > imported (and run) more than once, but I haven't been able to find >

Re: package import

2008-02-06 Thread Sean Allen
Thanks. Found that 10 minutes after I sent. On Feb 6, 2008, at 4:57 AM, Diez B. Roggisch wrote: > Sean Allen wrote: > >> ok, what am i doing wrong? >> >> in current working directory i have: >> >> t.py >> sub/t1.py >> >> t.py is: >> >> import sub.t1 >> >> i get: >> >> ImportError: No module named

Re: package import

2008-02-06 Thread Diez B. Roggisch
Sean Allen wrote: > ok, what am i doing wrong? > > in current working directory i have: > > t.py > sub/t1.py > > t.py is: > > import sub.t1 > > i get: > > ImportError: No module named sub.t1 > > t.py is > > import sub > > i get: > > ImportError: No module named sub.t1 > > -- > > i am o

Re: package import

2008-02-05 Thread Steve Holden
Sean Allen wrote: > ok, what am i doing wrong? > > in current working directory i have: > > t.py > sub/t1.py > > t.py is: > > import sub.t1 > > i get: > > ImportError: No module named sub.t1 > > t.py is > > import sub > > i get: > > ImportError: No module named sub.t1 > > -- > > i am ob

Re: package import question

2007-10-22 Thread Phoe6
On Oct 22, 1:24 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > Phoe6 wrote: > > Hi all, > > I have the following directory structure: > > > wallpaper/ > > -main.py > > -ng/ > > -- __init__.py > > -- setdesktop.py > > -yb/ > >

Re: package import question

2007-10-22 Thread Peter Otten
Phoe6 wrote: > Hi all, > I have the following directory structure: > > wallpaper/ > -main.py > -ng/ > -- __init__.py > -- setdesktop.py > -yb/ > -- __init__.py > -- setdesktop.py > >>Fro

Re: package import question

2007-10-22 Thread Diez B. Roggisch
Phoe6 wrote: > Hi all, > I have the following directory structure: > > wallpaper/ > -main.py > -ng/ > -- __init__.py > -- setdesktop.py > -yb/ > -- __init__.py > -- setdesktop.py > >>Fro