r/backtickbot • u/backtickbot • Jul 22 '21
https://np.reddit.com/r/Python/comments/opb7hm/do_not_use_mutable_objects_as_default_arguments/h66kqpe/
Yeah, maybe the or trick is good for code golf but it doesn't seem good for much else. You see the code:
if arr is None:
arr = []
and the equivalent one-liner is:
arr = [] if arr is None else arr
not some obfuscated nonsense involving evaluating datastructures as boolean and messing up the types.
1
Upvotes