3 ms·
do people use x = x or [] or is it considered non idiomatic in python ?
by agumonkey 8y ago
do people use
x = x or []
or is it considered non idiomatic in python ?
- tomchristie 8y agoIt’s okay-ish. You do need to be careful about what falsey values `x` might be tho, as it could introduce edge-case bugs. Using `x = [] if x is None else x` is more precise.
- Asooka 8y agoI would really just write `if x is None: x = []`