Is it possible to have a static variable in Python - 
a local variable in a function that retains its value.

 For example, suppose I have:

def set_bit (bit_index, bit_value):
   static bits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
   bits [bit_index] = bit_value

   print "\tBit Array:"
   int i
   while (i < len(bits):
      print bits[i],
   print '\n'

 
   I realize this can be implemented by making bits global, but can
this be done by making it private only internal to set_bit()?  I don't
want bits to be reinitialized each time. It must retain the set values
for the next time it is called.


Thanks in advance:
Michael Yanowitz



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

Reply via email to