re: Python Mutable Defaults Are The Source of All Evil VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Would you consider seq = seq or [] a viable alternative to your if-construction?
 

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.
code of conduct - report abuse