[Tutor] __init__, default values and dict's

Alan Gauld alan.gauld at btinternet.com
Thu Aug 14 19:32:15 CEST 2008

"Bart Cramer" <bart.cramer at gmail.com> wrote

> Does anybody know why this is the case? And what would be the most
> convenient solution to enforce the dynamic creation of the 
> dictionary?

Kent answered the first bit.

For the second try

def __init__(self, d=None):
    if not d:
         d = {}
   self.d = d


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list