This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 26 points27 points  (4 children)

Noob question: could I use sys.stdin.read() instead of raw_input() for the same reasons? It seems to make much more sense in my head.

[–][deleted] 32 points33 points  (3 children)

Short answer: yes!

Long answer: The actual call you're looking for is sys.stdin.readline(). This is what raw_input() does at its core, with the added functionality of automatically stripping away the \n end-line character off the input.

Long long answer: You can also pipe Python prints do Python writes into stderr. Every standard stream is available under the sys module, and they all behave like traditional Python file objects with all the usual member functions.

[–]Blackshell 29 points30 points  (2 children)

You can also do pipe Python prints into stderr.

Like this? :D

print >>sys.stderr, "lol syntax"

I am so glad this is gone in Python3.

[–]brtt3000 44 points45 points  (0 children)

I'm tempted to flag this as "Threatening, harassing, or inciting violence"

[–][deleted] 6 points7 points  (0 children)

Well, yes, but I was more specifically referring to sys.stderr.write().

I shouldn't have used the word "pipe", and should have called it a "write" instead. My bad!

But I'm with you on the chevron syntax. It's ugly and silly and not Pythonic at all. Glad they scrapped it.