how to safely extract dict values

Paul Rubin http
Mon Jul 31 06:46:13 EDT 2006


Bruno Desthuilliers <onurb at xiludom.gro> writes:
> Too much useless lookup IMHO...

Actually, you, me, and Amit all mis-read David's original exapmle.
What he really wanted was (let's see if I get it right this time):

   if mykey in mydict:
      v = mydict[mykey]
      if not isinstance(v, list):
         v = [v]
      for val in v: ...



More information about the Python-list mailing list