Python Forum
which is "better" (or more Pythonic)?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
which is "better" (or more Pythonic)?
#1
i have a little function that i am considering whether or not i should use a variable for some intermediate data:

form 1:
    ...
    with Popen(cmd,stdout=PIPE,universal_newlines=all(isinstance(x,str)for x in cmd)) as p:
        return p.stdout.read().splitlines()
or

form 2:
    ...
    un = all(isinstance(x,str)for x in cmd))
    with Popen(cmd,stdout=PIPE,universal_newlines=un) as p:
        return p.stdout.read().splitlines()
should i use the extra variable or not? i'm sure it would slow things down a minuscule undetectable amount.

i did indent the above code by 4 more spaces than it shows in the preview.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
which is "better" (or more Pythonic)? - by Skaperen - Nov-16-2019, 01:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  which is "better" (or more Pythonic)? Skaperen 2 2,081 Feb-01-2020, 03:10 PM
Last Post: Skaperen
  which is "better" (or more Pythonic)? Skaperen 7 3,264 Feb-01-2020, 03:51 AM
Last Post: Skaperen
  which is more Pythonic? Skaperen 5 2,898 Jul-16-2019, 01:00 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020