Cashing in PythonWin name space?... seems unexpected to me

bsneddon bsneddon at yahoo.com
Thu Oct 8 09:47:17 EDT 2009


I saw an issue  on winXP  box not connected to internet yesterday,
where i was running
a script in the interactive window on PythonWin .   I would modify the
script save and
import and was still running the old version.  I did that several
times with same result.
I even renamed the function and it showed up but ran the old script.
Very strange.

I tried reproducing this morning on a machine that is connected to
internet was unable to
but did get the behavior below that I do not understand.

created module named spam with this code.
def ello():
    print "Your father smells of elderberrys"

Here is expert for interactive window to explain the issue: question
is below.

PythonWin 2.6 (r26:66721, Oct  2 2008, 11:35:03)
I


renamed ello to insult and re-imported.

>>> dir(spam)
[clip.. 'ello', 'insult']

ello still exist in namespace an runs ... not so strange
>>> spam.ello()
Your father smells of elderberrys

>>> del(spam)
delete spam and it no longer runs as expected.

modify insult to this:
def insult():
    print "Your father smells of elderberrys/n and your mother was a
kiniggit"

Q.
on re-importing spam ello is back and continues to run.   I did note
expect this to be the
case.  Can someone explain what is happening?

>>> dir(spam)
[clip..., 'ello', 'insult']
>>> spam.ello()
Your father smells of elderberrys
>>> spam.insult()
Your father smells of elderberrys/n and your mother was a kiniggit
>>>


Thanks for your help.

Bill Sneddon



More information about the Python-list mailing list