Twice instanciation

Salvatore artyprog at wanadoo.fr
Thu Jun 12 23:06:19 CEST 2003


W Isaac Carroll wrote:

> Salvatore wrote:
> 
>> Hello,
>>
>> Is it possible to avoid twice instanciation
>> of the same variable ?
>>
>> class Global:
>>    def __init__(self,init=0):
>>       self.value = init
>>
>> g = Global() #instanciating one time ok
>> g = Global() #instanciating two times would raise an exception
> 
> 
> What do you mean by "instanciation" and "variable"?
> 
> If you are asking whether it's possible to prevent binding the same name 
> a second time, then no, it's not possible.

That's it - excuse my poor English ;-)

As I said to Manual, i'll propose another solution.

Thanks Isaac









More information about the Python-list mailing list