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)?
#7
(Nov-16-2019, 06:43 AM)Gribouillis Wrote: The whole thing seems unpythonic to me. If true, the universal_newline argument indicates that the subprocess' streams should be opened in text mode. Why link this to the fact that the command's arguments have the python type 'str'? This is an unpythonic use of types. Also note that isinstance() should be rarely used in pythonic code.
see DeaD_EyE's quote. see the sentence after the one he underlined. By default, file objects are opened in binary mode. and that's what i see happening.

as for types, i am using byte strings more and more now that i do all in only Python3 and more stuff gives my bytes to work with. so when i have functions or sections of code (that eventually become functions) taking some string and resulting in some string, i try to make it str->str and bytes->bytes as much as i can. if i'm using this code/function where bytes are being used, i want to be consistent. i don't want to have to always be converting str back to bytes.

i got used to using Popen() instead of run() because most of my uses involve parallelism which run() does not give me since it waits for the process to finish. of course, there are these cases where i do want to wait for completion. so out of habit i do use Popen(). when writing a function that creates a process, i have to think about the purpose of the function and understand if the caller is calling for the purpose of launching the process, or some other. it does look like i should (and probably can) change my uses of call() to run(). my default kit of imports does, already, include run().
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
RE: which is "better" (or more Pythonic)? - by Skaperen - Nov-16-2019, 06:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  which is "better" (or more Pythonic)? Skaperen 2 2,113 Feb-01-2020, 03:10 PM
Last Post: Skaperen
  which is "better" (or more Pythonic)? Skaperen 7 3,332 Feb-01-2020, 03:51 AM
Last Post: Skaperen
  which is more Pythonic? Skaperen 5 2,956 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