Twice instantiation - a solution

Salvatore artyprog at wanadoo.fr
Fri Jun 13 19:14:45 CEST 2003


Thanks to Anton Muhin and all of you  of course

 >>> from functional import *
 >>> class Global:
	def __init__(self,init=0):
		self.value = init

		
 >>> let = Bindings()
 >>> let.g = Global(6)
 >>> let.g = Global(4)
Traceback (most recent call last):
   File "<pyshell#40>", line 1, in ?
     let.g = Global(4)
   File "C:\Developpement\Python22\lib\functional.py", line 1026, in 
__setattr__
     raise BindingError, "Binding '%s' cannot be modified." % name
BindingError: Binding 'g' cannot be modified.
 >>> let.v = Global(6)
 >>> let.v = Global(5)
Traceback (most recent call last):
   File "<pyshell#42>", line 1, in ?
     let.v = Global(5)
   File "C:\Developpement\Python22\lib\functional.py", line 1026, in 
__setattr__
     raise BindingError, "Binding '%s' cannot be modified." % name
BindingError: Binding 'v' cannot be modified.
 >>>


Salvatore





More information about the Python-list mailing list