3 ms·
Pipelines like this tend to come in two flavors: 1. Long, unreadable, and undebuggable (since you can't step through them) 2. Ones you wish could have just be
by Noumenon72 7y ago
Pipelines like this tend to come in two flavors:
1. Long, unreadable, and undebuggable (since you can't step through them)
2. Ones you wish could have just been a Python list comprehension:
return [f"car-#{n}" for n in range (1,6) if car_is_empty(n)]
- pritambaral 7y agoYour list comprehension example is incorrect: car_is_empty() takes the id string, not number.
- Noumenon72 7y agoI'm sorry, I actually didn't get what the code was trying to do. Result should have been named "empty_car_ids" to signal. What is this "select" function, why isn't it called filter? I actually don't know how to Google this because the HTML select gets in the way. I'd really do it in two lines, because I want to get the first half right and then the second, and be able to inspect the first half independently of the second while debugging. The pipelines don't let you do that. car_ids = [f"car-#{n}" for n in range (1,6)] empty_car_ids = [id for id in car_ids if car_is_empty(id)]
- valuearb 7y agoIf I were to teach a professional programming class, I’d automatically fail the most concise entries, whether they worked or not.