4 ms·
My reaction was to the "sys.stdout.write" statement. Who does that?
by matmann2001 11y ago
My reaction was to the "sys.stdout.write" statement. Who does that?
- mbvf 11y agoMy reaction was: 1) Jeez, who comments their code in a such crisis situation then, 2) Man, no wonder he got selected. He must be a good programmer
- eliben 11y agoIt's actually one alternative to Python 2/3 compatibility, working around the fact that print is a statement in 2, and just a function in 3. The more common way is "from __future__ import print_function" of course, but I've seen code that does sys.stdout.write instead -- nothing wrong about that (especially if your code usually uses streams for stuff)
- matmann2001 11y agoI understand how one might use sys.stdout.write, but the reasons for doing so are kind of rare. When you're pressed for time to reverse the security protocols and escape, ensuring backwards/forwards compatibility seems like a low priority.
- eliben 11y agoFor sure. I was just giving a reasoning why such code makes sense at all; I wasn't trying to defend its usage in the given context :)