Posts: 4,647
Threads: 1,494
Joined: Sep 2016
how acceptable is it to do this:
[print(x)for x in foo]
instead of this:
for x in foo:
print(x)
now that my thinking includes readily throwing away data which an optimizing compiler can avoid.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
thank you for input. i will avoid those.
the reason i'm always looking for ways to reduce lines is to see more code in my finite size screen display. my current project is a command to download and process specific cloud data and it is just about to reach 700 lines. yes, there are some empty lines where spacing helps readability. my screen only has 34 rows, now that i switched to a larger font.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
if i have to jump around a lot to see the big picture, i haven't gained by going small. but identifying cases where some code can be reusable standing on its own, then that part can be maintained on its own.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i can see the overall code easier if it fits on my 34 (35, but the bottom line is hard to make use of) line screen. when some part of the logic gets moved to be inside a function located far far away, then all i can see is the call to it. if the call itself makes sense then i can still see the big picture. but if it doesn't, then i can no longer see the big picture. often, the block of code in a loop has "side effects" if it were made into a function.
but i have already agreed not to use a comprehension, purposelessly. that is if it throws away what it just created, it had no true purpose being a comprehension. OTOH, using that value for something would generally justify it.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.