Static Variables in Python?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Mon Jul 31 15:57:55 EDT 2006


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




More information about the Python-list mailing list