Unexpected python behaviour
Jay O'Connor
joconnor at cybermesa.com
Fri Nov 28 10:14:44 EST 2003
Richard Philips wrote:
> 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.
That caught me by suprise to, especially because after running it,
'drivers' is not defined
More information about the Python-list
mailing list