Posts by lorenzo@neuromatch.social
 (DIR) Post #ARVFrvj2uKQATRZFDc by lorenzo@neuromatch.social
       2023-01-10T13:01:18Z
       
       1 likes, 3 repeats
       
       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
       
 (DIR) Post #ARVIvJQxW6qOjdPbE0 by lorenzo@neuromatch.social
       2023-01-10T15:15:43Z
       
       1 likes, 0 repeats
       
       @ML2 Yes that's the correct pattern! Someone once told me to use "is None" since "is" is not overloadable (the == operator is) but I guess it doesn't make much difference in practice.