nate wrote:
> try this:
>
> gname = 'nate'
> def test():
>    gname = 'amy'
>    print gname
>
> test()
> print gname
>
> outputs:
> 'amy'
> 'nate'
>
> whereas this:
> gname = 'nate'
> def test():
>    global gname
>    gname = 'amy'
>    print gname
>
> test()
> print gname
>
> outputs:
> 'amy'
> 'amy'
OK, so I should include the global only if I plan to modify it.
Otherwise, I don't need to include it. Am I right?

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to