3 ms·
Absolutely. Not using mutable variables as default arguments = 91%
by EToS 9y ago
Absolutely. Not using mutable variables as default arguments = 91%
- milesrout 9y agoPython doesn't have 'mutable variables'. I think you mean 'not binding mutable values as default arguments', but that's totally fine. What's wrong is not understanding when default arguments are bound. There's nothing inherently wrong with this: class Wrapper: def __init__(self, wrapped): self.wrapped = wrapped def counter(): def inner(w=Wrapper()): w.wrapped += 1 return w return inner