[Tutor] help, thanks very much.

bill.wu bill.wws at gmail.com
Wed Jan 16 02:31:07 CET 2008


i am new guy.
i ask a easy question.
 
why the first one have"x",the second one doesn't have "x". what is different? when write "x",when don't write "x".

in my point,the second one don't def variable.

(1)

def func(x):
    print 'x is', x
    x = 2
    print 'Changed local x to', x

x = 50
func(x)
print 'x is still', x (2)

def func():
    global x

    print 'x is', x
    x = 2
    print 'Changed local x to', x

x = 50
func()
print 'Value of x is', x 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080116/220cd6f2/attachment.htm 


More information about the Tutor mailing list