[Python-au] strange pre-acting bug
Garry Trethewey
garrytre at bigpond.com
Wed May 19 02:33:52 UTC 2010
thank you PeterL & Ryan
PeterL wrote:
> Passing parameters is probably the best way.
> You can also resolve the scope using the global keyword.
> ----
> def fn():
> global x
> print x # Prints 5
> x = 7
> print x # Prints 7
>
> x = 5
> print x # Prints 5
> fn()
> print x # Prints 7
> -------------
> Some consider global a 'kludge' that leads to poor programming style.
> I'm one of them.
>
> Yes, a function is 'compiled' in it's entirety before it gets used, so
> there is a bit of 'oh this happens later' happening.
> Pete
>
--
------------------------------------
Garry Trethewey
------------------------------------
More information about the python-au
mailing list