newbie questions

houbahop d.lapasset
Sat Dec 11 20:19:07 CET 2004


Hello again everyone ,
var2[:]=[] has solved my problem, and I don't understand why it is 
programming by side effect.
I don't think it's bad, look at this, it's what I've done :

def Clear(lvar)
    lvar[:]=[]

def main (starting class)
   var1=[]
   var1.append('a')
   Clear(var1)

var1 can only be modified by  Clean(), so, if I need to debug var1, I 
quickly know that I must look in Clean()


For me programming by side effect is that :

def Clear(lvar)
    var1=[]

def main (starting class)
   global var1=[]
   var2=[]
   var1.append('a')
   Something(var2)


I am wrong?
Dominique. 





More information about the Python-list mailing list