embarrassing class question

Peter Pearson ppearson at nowhere.invalid
Fri Oct 22 19:21:14 CEST 2010


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):
>     pass
> class WZX(z.ZX):
>     pass
> class WZY(z.ZY):
>     pass
>
>>>> import x, y, z, w
>>>> dir(x)
> ['X', '__builtins__', '__doc__', '__file__', '__name__',
> '__package__']
>>>> dir(y)
> ['Y', '__builtins__', '__doc__', '__file__', '__name__',
> '__package__', 'x']
>>>> dir(z)
> ['ZX', 'ZY', '__builtins__', '__doc__', '__file__', '__name__',
> '__package__', 'x', 'y']
>>>> dir(w)
> ['WX', 'WY', 'WZX', 'WZY', '__builtins__', '__doc__', '__file__',
> '__name__', '__package__', 'x', 'y', 'z']

I apologize for being dense, but I don't understand what bothers
you about this behavior.  Yes, module w imports x, and therefore
w.x exists.  Is that bad?


-- 
To email me, substitute nowhere->spamcop, invalid->net.



More information about the Python-list mailing list