Scope
Elliot Temple
curi at curi.us
Fri Jun 3 22:17:25 EDT 2005
On Jun 4, 2005, at 2:13 AM, Leif K-Brooks wrote:
> Elliot Temple wrote:
>
>> I want to write a function, foo, so the following works:
>>
>> def main():
>> n = 4
>> foo(n)
>> print n
>>
>> #it prints 7
>>
>
> What's wrong with:
>
> def foo(n):
> return 7
>
> def main():
> n = 4
> n = foo(n)
> print n
>
> Anything else (including the tricks involving mutable objects that
> will
> no doubt be posted) will result in ugly, hard to maintain code.
Nothing is wrong with it in this case. I just want to know if Python
can do what I said.
-- Elliot Temple
http://www.curi.us/
---
[This E-mail scanned for viruses by Declude Virus]
More information about the Python-list
mailing list