DEV Community

Discussion on: Python Mutable Defaults Are The Source of All Evil

Collapse
 
mrgnth profile image
Thomas Schmitt

Would you consider

seq = seq or []

a viable alternative to your if-construction?

Collapse
 
florimondmanca profile image
Florimond Manca • Edited

Yes, I would see that as a viable alternative :-) — although I would argue that:

  • I see the if X is None check in Python code more often — not sure it means anything in terms of "pythonicism", though!
  • This only works when the default is simple enough to build. If it needs multiple lines to be built, we'll have to resort to if X is None anyway.