(Nov-16-2019, 06:43 AM)Gribouillis Wrote: The whole thing seems unpythonic to me. If true, thesee 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.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 thatisinstance()
should be rarely used in pythonic code.
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.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.