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 >

package import dangers

2009-10-06 Thread Ethan Furman
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 actual examples of such failing