|
|
|
|
|
by jmcomets
3393 days ago
|
|
One-liners are bad if they are obscure and experienced programmers know that. However I wouldn't go as far as say that experienced programmers don't use one-liners at all. As usual in programming, it's all about balancing clarity/conciseness. For example, I find this much clearer as a one-liner (Python): validated_items = filter(is_validated, items)
rather than validated_items = []
for item in items:
if is_validated(item):
validated_items.append(item)
|
|
validated_items = [x for x in items if is_validated(x)]