Re: embarrassing class question

2010-10-30 Thread Gregory Ewing
Paul Rudin wrote: Gregory Ewing greg.ew...@canterbury.ac.nz writes: You can clean up dir() by defining __all__ as a list of names that you want to officially export. I'm not sure that's necessarily a good idea... when you're trying to figure out why something behaves in a certain way you

Re: embarrassing class question

2010-10-30 Thread Steven D'Aprano
On Sat, 30 Oct 2010 19:30:21 +1300, Gregory Ewing wrote: (BTW, there are no function names that have a special meaning in a module dict -- a module is not like a class.) Pity... it would be nice to have a __main__() function, or perhaps main(), that was automatically called when you call the

Re: embarrassing class question

2010-10-29 Thread Gregory Ewing
Brendan wrote: I use Python sporadically, and frequently use the dir command to learn or remind myself of class methods. You can clean up dir() by defining __all__ as a list of names that you want to officially export. Other names will still be there, but they won't show up in the dir()

Re: embarrassing class question

2010-10-29 Thread Paul Rudin
Gregory Ewing greg.ew...@canterbury.ac.nz writes: Brendan wrote: I use Python sporadically, and frequently use the dir command to learn or remind myself of class methods. You can clean up dir() by defining __all__ as a list of names that you want to officially export. Other names will

Re: embarrassing class question

2010-10-29 Thread Lawrence D'Oliveiro
In message 8idvgaf21...@mid.individual.net, Peter Pearson wrote: Yes, module w imports x, and therefore w.x exists. Is that bad? No-one seems to have come out and said this yet (unless it was in one of those messages that no longer seem to be accessible on my ISP’s news server): Python has

Re: embarrassing class question

2010-10-25 Thread Brendan
On Oct 22, 2:21 pm, Peter Pearson ppear...@nowhere.invalid wrote: On Fri, 22 Oct 2010 07:49:39 -0700 (PDT), Brendan wrote: [snip] x.py class X(object):     pass y.py import x class Y(x.X):     pass z.py import x import y class ZX(x.X):     pass class ZY(y.Y):  

Re: embarrassing class question

2010-10-22 Thread Steven D'Aprano
On Thu, 21 Oct 2010 12:12:34 -0700, Brendan wrote: Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted text - So what is usually done to prevent this? (In my case not wanting class x added to the y.py

Re: embarrassing class question

2010-10-22 Thread Brendan
On Oct 22, 5:02 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 21 Oct 2010 12:12:34 -0700, Brendan wrote: Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted text - So what is

Re: Re: embarrassing class question

2010-10-22 Thread Dave Angel
On 2:59 PM, Brendan wrote: On Oct 21, 3:56 pm, Ethan Furmanet...@stoneleaf.us wrote: snip Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted text - So what is usually done to prevent this? (In my case not

Re: embarrassing class question

2010-10-22 Thread Brendan
On Oct 22, 9:16 am, Dave Angel da...@dejaviewphoto.com wrote: On 2:59 PM, Brendan wrote: On Oct 21, 3:56 pm, Ethan Furmanet...@stoneleaf.us  wrote: snip Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted

Re: embarrassing class question

2010-10-22 Thread Peter Pearson
On Fri, 22 Oct 2010 07:49:39 -0700 (PDT), Brendan wrote: [snip] x.py class X(object): pass y.py import x class Y(x.X): pass z.py import x import y class ZX(x.X): pass class ZY(y.Y): pass w.py import x import y import z class WX(x.X): pass class WY(y.Y):

embarrassing class question

2010-10-21 Thread Brendan
Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not understand why class 'x' shows up here. --

Re: embarrassing class question

2010-10-21 Thread Jonas H.
On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not understand why class 'x'

Re: embarrassing class question

2010-10-21 Thread Carl Banks
On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):     pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I

Re: embarrassing class question

2010-10-21 Thread Brendan
On Oct 21, 3:47 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):     pass Now from the python command line: import y dir(y)

Re: embarrassing class question

2010-10-21 Thread Ethan Furman
Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not

Re: embarrassing class question

2010-10-21 Thread Chris Rebert
On Thu, Oct 21, 2010 at 11:53 AM, Brendan brendandetra...@yahoo.com wrote: On Oct 21, 3:47 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):  

Re: embarrassing class question

2010-10-21 Thread Robert Kern
On 10/21/10 1:53 PM, Brendan wrote: On Oct 21, 3:47 pm, Carl Bankspavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendanbrendandetra...@yahoo.com wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command

Re: embarrassing class question

2010-10-21 Thread Ian
On Oct 21, 12:53 pm, Brendan brendandetra...@yahoo.com wrote: So it must never make sense to put subclasses in separate modules? It doesn't matter to Python whether the subclass is in the same module or imported. Do it whichever way makes the most sense to you from a code organization

Re: embarrassing class question

2010-10-21 Thread Brendan
On Oct 21, 3:56 pm, Ethan Furman et...@stoneleaf.us wrote: Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object):      pass y.py: from x import x class y(x):      pass Now from the python command line: import y dir(y)

Re: embarrassing class question

2010-10-21 Thread Carl Banks
On Oct 21, 11:53 am, Brendan brendandetra...@yahoo.com wrote: On Oct 21, 3:47 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):    

Re: embarrassing class question

2010-10-21 Thread Robert Kern
On 10/21/10 2:12 PM, Brendan wrote: On Oct 21, 3:56 pm, Ethan Furmanet...@stoneleaf.us wrote: Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y