Unexpected python behaviour

Richard Philips richard.philips at ua.ac.be
Fri Nov 28 09:26:51 EST 2003


Consider the script:

def test(drivers={}):
    if drivers:
        print drivers
    else:
        drivers["A"] = "B"

if __name__  == "__main__":
    test()
    test()

prints in stdout:
{'A': 'B'}

I expected that nothing would be displayed.
I do not understand this behaviour (python2.3 on WinXP and Linux).

If anybody can explain this situation, you are welcome.

Thank you.


-- 
================================================================
Dr. Richard PHILIPS
University of Antwerp
Systemmanager Anet

Phone: +32 3 820.21.53
Fax:   +32 3 820.21.59
GSM:   0478/36.76.28
Email: Richard.Philips at ua.ac.be
================================================================








More information about the Python-list mailing list