Posting this because it can save some lives. If you use an empty list or dictionary as a default argument in #python, the same list will be used every time. So every call will just update the mutable element instead of re-defining it as empty 😱

Most IDEs will give you a vague warning (PyCharm does) but nothing more so it can be very sneaky and dangerous!

#coding #programming #killerbugs

Follow

@lorenzo I've played with python before and didn't like it very much. But now I think I'll never use python again. What a stupid design decision.... I understand why it is so....but it's still wrong. :ablobheadshake:

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.