--- Karl Pflästerer <[EMAIL PROTECTED]> schrieb:

> 
> The values of optional arguments are only once
> evaluated (when Python
> reads the definition). If you place there mutable
> objects like e.g. a
> list most of the time the effect you see is not what
> you want. So you
> have to write it a bit different.
> 
>      def __init__(self, q = None):
>          if not q: q = []
>          self.queue = q
> 
> or
> 
>      def __init__(self, q = None):
>          self.queue = q or []
> 
> Now you get a fresh list for each instance.
> 
>    Karl

Thank you very much. I will use your code as a
"recipe", while I still try to understand the
mechanism and the reasons behind it. For me this feels
odd.  

Barb




        

        
                
___________________________________________________________ 
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: 
http://mail.yahoo.de
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to