Package name with '.' in them: Python Bug ?

Terry Reedy tjreedy at
Fri Mar 19 21:52:54 CET 2004

"Yannick Patois" <patois at> wrote in message
news:c3fd5j$mlg$1 at
> Terry Reedy wrote:
> > Since 'static variable' is not a Python concept, I do not know what you
> > mean.

> how do you call 'a' in class A ?

(non-method) attribute, possibly 'member' (of class A).

> > Given that you rebound A.a to 1 from None, I especially do not know
> > you mean.
> I dont understand.

When you call this class

> <<<< file:
> class A:
>      a=None
>      def __init__(self,a=None):
>          if (a):
>              A.a=a

with the statement a=A.A(1), you enter __init__ with a==1, trigger the
if(a) [if(1)]conditional and execute A.a=a [A.a=1], thereby rebinding class
attribute a from None, as originally set, to 1.  Leaving aside the misuse
of 'static' in C, 'static' usually means 'unchanging', whereas you change

> > As you seem to be aware, Python expects modules to have a 'nice' name
> > consisting of
> >
> Which are ? Where to find this info ?

Tutorial I presume, definitely Reference Manual under 'names' and/or

> >  If you evade this, you are a bit on your own
> > and may run into untested corner cases.
> Untested area contains bugs, that's why it's interesting to test them.

Yes, I have done similar things.

> > I would put more print statements into both A.A and B.B
> > and maybe even to see where execution first differs.

To restate: if I were to investigate further, I would add prints
statements, since that has so far worked well for me with Python.  What you
do is up to you.

> It breaks in B, if I remember well.

In what way?  Since the line  'a=A.A(1)', should still rebind A.a, it is
puzzling that the following line 'b=B.B()' should act any differently.  The
only thing I can think of is that the name change caused the line 'import
A' to import A under a different internal name so that module A in B is no
longer that same as module A in aTest.  I would test this by putting 'print
id(A)' in both files after the imports.  I would also add

import sys
print sys.modules

to the end of aTest.  I suspect that this will clear up the mystery.

Terry J. Reedy

More information about the Python-list mailing list