small python code refactor

Posted by hyperboreean on Stack Overflow See other posts from Stack Overflow or by hyperboreean
Published on 2010-05-12T14:18:45Z Indexed on 2010/05/12 14:24 UTC
Read the original article Hit count: 200

Filed under:

I am having this piece of code, which in my opinion is fairly ugly and I am wondering how it can be done better:

if dict.get(key, None) is None:
   dict[key] = None

Points for elegance ;-)

© Stack Overflow or respective owner

Related posts about python