Python 2.3[color=blue][color=green][color=darkred]
>>> def foo():[/color][/color][/color]
.... foo.a = 1
....[color=blue][color=green][color=darkred]
>>> vars(foo)[/color][/color][/color]
{}[color=blue][color=green][color=darkred]
>>> foo()
>>> vars(foo)[/color][/color][/color]
{'a': 1}[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
So it would appear that function attributes are not really
there until the first call to the function. If that is the
intended behaviour, it is really weird. I couldn't find any
explicit discussion of this topic in the LRM.
Thanks if anyone can shed some light on this,
-- O.L.
>>> def foo():[/color][/color][/color]
.... foo.a = 1
....[color=blue][color=green][color=darkred]
>>> vars(foo)[/color][/color][/color]
{}[color=blue][color=green][color=darkred]
>>> foo()
>>> vars(foo)[/color][/color][/color]
{'a': 1}[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
So it would appear that function attributes are not really
there until the first call to the function. If that is the
intended behaviour, it is really weird. I couldn't find any
explicit discussion of this topic in the LRM.
Thanks if anyone can shed some light on this,
-- O.L.
Comment