amazing scope?
Jean-Michel Pichavant
jeanmichel at sequans.com
Fri Nov 30 11:47:17 EST 2012
----- Original Message -----
> Well I knew that this works fine, even if I feel a bit guilty to do
> this, and better is:
>
> foo = 'bar' if some_condition else 'baz'
>
> Anyway for me the suprise is that something that is defined *later*
> at
> the module scope is found in a function which is defined *earlier*.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
What really matters for function is when they're executed, not defined (except for their parameter default value).
foo = 'I am foo'
bar = 'I am bar'
def funcA(param1=foo):
print param1
print bar
foo = 'I am another foo'
bar = 'I am another bar'
def funcB(param1=foo):
print param1
print bar
funcA()
funcB()
I am foo
I am another bar
I am another foo
I am another bar
cheers,
JM
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the Python-list
mailing list