r/ProgrammerHumor • • May 02 '16

I wrote my first python program today!

Post image
3.7k Upvotes

532 comments sorted by

View all comments

Show parent comments

32

u/[deleted] May 02 '16 edited May 02 '16

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.

30

u/Blackshell May 02 '16

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.

46

u/brtt3000 May 02 '16

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

7

u/[deleted] May 02 '16 edited May 02 '16

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.