[EMAIL PROTECTED] wrote:
> tac-tics:
>> If you declare bits in set_bit() as "global bits = ...", it will create
>> it as a global variable without you having to declare it outside of the
>> function. Just be careful about name conflicts.
> 
> Are you sure?
> 
> def fun():
>     global x = 10
> fun()
> print x
> 
> Bye,
> bearophile
> 

This works for me:

 >>> def fun():
        global x
        x = 10

        
 >>> fun()
 >>> print x
10
 >>>

But of course:

 >>> def fun():
        global x = 10
        
SyntaxError: invalid syntax
 >>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to