the annoying, verbose self

greg greg at
Sun Nov 25 00:29:33 CET 2007

Patrick Mullen wrote:
> Sometimes I actually use a dictionary, but typing all of the quotes
> for the keys gets old.

If the keys are all identifiers, you can use keyword
args to the dict constructor. So you could write

   self.__dict__.update(dict(var1 = 5,
     var2 = "a value", var3 = stuff))

if you really wanted to. (Don't be surprised if
everyone else refuses to maintain your code, though!)


More information about the Python-list mailing list