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
Paul Rudin wrote:
Gregory Ewing 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 want to check for the
presence
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
Gregory Ewing 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
> still be there, but
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() listing
On Oct 22, 2:21 pm, Peter Pearson 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
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):
>
On Oct 22, 9:16 am, Dave Angel wrote:
> On 2:59 PM, Brendan wrote:> On Oct 21, 3:56 pm, Ethan
> Furman 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 usu
On 2:59 PM, Brendan wrote:
On Oct 21, 3:56 pm, Ethan Furman 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 th
On Oct 22, 5:02 am, Steven D'Aprano 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 usually done to prevent
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 th
On 10/21/10 2:12 PM, Brendan wrote:
On Oct 21, 3:56 pm, Ethan Furman 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)
['__builtins
On Oct 21, 11:53 am, Brendan wrote:
> On Oct 21, 3:47 pm, Carl Banks wrote:
> > On Oct 21, 11:09 am, 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
On Oct 21, 3:56 pm, Ethan Furman 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
> >
On Oct 21, 12:53 pm, Brendan 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 perspective.
--
http://mail.pytho
On 10/21/10 1:53 PM, Brendan wrote:
On Oct 21, 3:47 pm, Carl Banks wrote:
On Oct 21, 11:09 am, 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_
On Thu, Oct 21, 2010 at 11:53 AM, Brendan wrote:
> On Oct 21, 3:47 pm, Carl Banks wrote:
>> On Oct 21, 11:09 am, 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 l
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 understand
On Oct 21, 3:47 pm, Carl Banks wrote:
> On Oct 21, 11:09 am, 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__',
On Oct 21, 11:09 am, 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 n
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' sh
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.
--
http://mail.python.o
22 matches
Mail list logo