Re: question about input() and/or raw_input()
On Sunday, January 19, 2014 10:29:58 AM UTC+5:30, Chris Angelico wrote: On Sun, Jan 19, 2014 at 3:43 PM, Rustom Mody wrote: Because these two pieces of code def foo(x): print x+1 def bar(x): return x+1 look identical (to a beginner at least) foo(3) 4 bar(3) 4 As do these pieces of code: def quux1(x): return str(x+1) def quux2(x): return hex(x+1)[2:] They do? quux1(2.3) '3.3' quux2(2.3) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 1, in quux2 TypeError: hex() argument can't be converted to hex If you want to give an irrelevant example at least give a correct one :D the difference between str and hex is an arcane difference (Ive never used hex) the difference between functions and procedures is absolutely basic. And python is worse than not just academic languages like haskell in this respect but even worse than C/Pascal etc. In Pascal, the difference between procedure and function is fundamental to the lang and is key to Pascal being good for academic purposes. In C, the difference is not so well marked but at least trivial code-examples found in books/the net wont run straight-off without some main-printf-etc boiler-plate. In python lots of easy to check examples run straight off -- convenient for programmers of course but a headache for teachers who are trying to set habits of minimal hygiene But we don't decry hex or str because of it. Every function has its use and purpose. If someone uses the wrong tool for the job, s/he will have to figure that out at some point - it doesn't mean the tool is wrong. If you're not using the REPL, print is critical. Don't assume everyone uses interactive mode. Everyone uses interactive mode is of course an unreasonable assumption Everyone needs to learn (something or other at some time or other) is not And print (especially in python) screws up the learning-curve tl;dr You are wearing 'professional programmer' hat I am wearing 'teacher' hat Not sure what hat Roy or Steven are wearing -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sun, Jan 19, 2014 at 7:26 PM, Rustom Mody rustompm...@gmail.com wrote: If you want to give an irrelevant example at least give a correct one :D the difference between str and hex is an arcane difference (Ive never used hex) the difference between functions and procedures is absolutely basic. They don't give the same result for every possible input, any more than your two do: foo(1.234567890123456) 2.23456789012 bar(1.234567890123456) 2.234567890123456 (Tested on 2.7.3 on Linux. YMMV.) There's no difference in Python between functions and procedures. It's all functions, and some of them implicitly return None. If there were a difference, what would this be? def none_if(value, predicate): if not predicate(value): return value Personally, I'm quite happy with Python and the print function. (Or statement, if you prefer. Same difference.) The most fundamental aspects of any program are input, output, and preferably some computation in between; and the most fundamental forms of input are the command line / console and the program's source, and the most basic output is the console. So the most basic and obvious program needs: 1) Access to the command-line arguments 2) The ability to read from the console 3) Some means of writing to the console. Not every program will need all that, but they'd be the most obvious and simplest methods of communication - especially since they're the three that are easiest to automate. How do you run a GUI program through automated testing? With difficulty. How do you run a stdio program through automated testing? Pipe it some input and compare its output to the standard. And that means people should be accustomed to using print, and sys.argv, and (raw_)input. Fortunately Python doesn't have ob_start() / ob_get_clean() to tempt people to use print when they should use return. So there's no problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 2014-01-18, Terry Reedy tjre...@udel.edu wrote: On 1/18/2014 1:30 PM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Homework problems (and 'toy' programs, such as hangman), whether in a programming class or elsewhere, are one of the intended use cases of Python. How else would you get interactive input without the complexity of a gui? sys.stdin.readline() -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 01/19/2014 12:26 AM, Rustom Mody wrote: On Sunday, January 19, 2014 10:29:58 AM UTC+5:30, Chris Angelico wrote: On Sun, Jan 19, 2014 at 3:43 PM, Rustom Mody wrote: As do these pieces of code: -- def quux1(x): return str(x+1) -- def quux2(x): return hex(x+1)[2:] They do? -- quux1(2.3) '3.3' -- quux2(2.3) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 1, in quux2 TypeError: hex() argument can't be converted to hex (Will be) fixed in 3.5 [1] :) -- ~Ethan~ [1] Which is to say, both will raise an exception. -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Mon, Jan 20, 2014 at 3:14 AM, Ethan Furman et...@stoneleaf.us wrote: -- def quux1(x): return str(x+1) -- quux1(2.3) '3.3' (Will be) fixed in 3.5 [1] :) [1] Which is to say, both will raise an exception. Why would that raise? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 2014-01-19, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 19 Jan 2014 16:14:48 + (UTC), Grant Edwards invalid@invalid.invalid declaimed the following: On 2014-01-18, Terry Reedy tjre...@udel.edu wrote: On 1/18/2014 1:30 PM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Homework problems (and 'toy' programs, such as hangman), whether in a programming class or elsewhere, are one of the intended use cases of Python. How else would you get interactive input without the complexity of a gui? sys.stdin.readline() At which point a simple: nm = raw_input(Enter your name: ) print Hello, , nm turns into (to duplicate the behavior WRT line endings, and to minimize the new features the student is exposed to) import sys sys.stdout.write(Enter your name: ) nm = sys.stdin.readline() nm.strip() sys.stdout.write(Hello, ) sys.stdout.write(nm) sys.stdout.write(\n) sys.stdout.flush() The question was how to get input without using a GUI. I presented an answer. You then conflated whether or not to use input with whether or not to use print and proceeded to construct and knock down a very nice straw man. Kudos. import sys print Enter your name: , nm = sys.stdin.readline().strip() print Hello, , nm Yes, a non-beginner would have been exposed to formatting operations and been able to condense the three .write() calls into one... 1) I don't get why you jumped on the whole print vs. string formatting thing. We're not talking about print vs write. We're talking about whether or not people use input and raw_input. I've been writing Python programs for 15 years, and I've never used either input or raw_input. 2) I didn't claim that sys.stdin.readline() was as simple as using input. I didn't claim it was preferable. I merely presented it as a refutation to the argument that if you don't use input/raw_input then you have to use a GUI toolkit. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Mon, Jan 20, 2014 at 4:42 AM, Grant Edwards invalid@invalid.invalid wrote: 2) I didn't claim that sys.stdin.readline() was as simple as using input. I didn't claim it was preferable. I merely presented it as a refutation to the argument that if you don't use input/raw_input then you have to use a GUI toolkit. I'd draw a subtle distinction here, btw. With sys.stdin.readline(), you're asking to read a line from standard input, but with (raw_)input(), you're asking to read one line from the console. If it's been redirected, that's going to be equivalent (modulo newline handling), but if not, it would make sense for (raw_)input() to call on GNU Readline, where sys.stdin.readline() shouldn't. Calling a method on a file-like object representing stdin feels lower level than ask the user for input with this prompt (which might well do more than that, too - eg it might flush sys.stdout). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 18/01/2014 18:41, Mark Lawrence wrote: On 18/01/2014 18:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Not me personally. I guess raw_input must have been used somewhere at some time for something, or it would have been scrapped in Python 3, not renamed to input. Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 2014-01-19, Mark Lawrence breamore...@yahoo.co.uk wrote: On 18/01/2014 18:41, Mark Lawrence wrote: On 18/01/2014 18:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Not me personally. I guess raw_input must have been used somewhere at some time for something, or it would have been scrapped in Python 3, not renamed to input. Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. Fair enough, but what do you do to pass the time _during_ Snooker being shown on TV? I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. -- Grant Edwards grant.b.edwardsYow! I want EARS! I want at two ROUND BLACK EARS gmail.comto make me feel warm 'n secure!! -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 01/19/2014 08:38 AM, Chris Angelico wrote: On Mon, Jan 20, 2014 at 3:14 AM, Ethan Furman et...@stoneleaf.us wrote: -- def quux1(x): return str(x+1) -- quux1(2.3) '3.3' (Will be) fixed in 3.5 [1] :) [1] Which is to say, both will raise an exception. Why would that raise? Sorry, should have read that closer. It will not raise. The difference I was thinking of is: %h % 3.14 # this works vs. hex(3.14) # this raises In 3.5 both will raise. Apologies for the noise. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
In article lbh4oc$nqv$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. What's so complicated? points = 501 for dart in throws(): if points - dart == 0 and dart.is_double(): raise YouWin if points - dart 0: continue points -= dart beer.drink() -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Mon, Jan 20, 2014 at 4:50 AM, Ethan Furman et...@stoneleaf.us wrote: The difference I was thinking of is: %h % 3.14 # this works vs. hex(3.14) # this raises In 3.5 both will raise. Now you have me *thoroughly* intrigued. It's not %h (incomplete format - h is a modifier), nor %H (unsupported format character). Do you mean %x? As of 3.4.0b2, that happily truncates a float: %x % 3.14 '3' Is that changing in 3.5? Seems a relatively insignificant point, tbh! Anyway, no biggie. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Mon, Jan 20, 2014 at 5:37 AM, Roy Smith r...@panix.com wrote: What's so complicated? points = 501 for dart in throws(): if points - dart == 0 and dart.is_double(): raise YouWin if points - dart 0: continue points -= dart beer.drink() assert victory raise beer ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 2014-01-19, Roy Smith r...@panix.com wrote: In article lbh4oc$nqv$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. What's so complicated? points = 501 for dart in throws(): if points - dart == 0 and dart.is_double(): raise YouWin if points - dart 0: continue points -= dart beer.drink() That looks like an algorithm for _playing_ darts. That I understand. I have two dartboards (one real, one electronic) and a coule decent sets of darts. It's watching darts on TV that I don't get. Actually, I don't really get watching any sort of sports on TV (even the ones I play). But there was just something about darts on TV that seemed particularly beyond the pale. -- Grant Edwards grant.b.edwardsYow! But they went to MARS at around 1953!! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 19/01/2014 18:15, Grant Edwards wrote: On 2014-01-19, Mark Lawrence breamore...@yahoo.co.uk wrote: On 18/01/2014 18:41, Mark Lawrence wrote: On 18/01/2014 18:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Not me personally. I guess raw_input must have been used somewhere at some time for something, or it would have been scrapped in Python 3, not renamed to input. Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. Fair enough, but what do you do to pass the time _during_ Snooker being shown on TV? I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. Just no comparison, darts and snooker. This is excellent though http://www.youtube.com/watch?v=sHnBppccI0o -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sun, Jan 19, 2014 at 12:17 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 19/01/2014 18:15, Grant Edwards wrote: On 2014-01-19, Mark Lawrence breamore...@yahoo.co.uk wrote: Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. Fair enough, but what do you do to pass the time _during_ Snooker being shown on TV? I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. Just no comparison, darts and snooker. This is excellent though http://www.youtube.com/watch?v=sHnBppccI0o Now that we're way off on the tangent of what some people consider boring and others don't, I'm really looking forward to watching curling in the upcoming Olympics. -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 19/01/2014 19:24, Larry Martell wrote: On Sun, Jan 19, 2014 at 12:17 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 19/01/2014 18:15, Grant Edwards wrote: On 2014-01-19, Mark Lawrence breamore...@yahoo.co.uk wrote: Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. Fair enough, but what do you do to pass the time _during_ Snooker being shown on TV? I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. Just no comparison, darts and snooker. This is excellent though http://www.youtube.com/watch?v=sHnBppccI0o Now that we're way off on the tangent of what some people consider boring and others don't, I'm really looking forward to watching curling in the upcoming Olympics. Curling, now there's another good reason to allow Scottish independance :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 01/19/2014 10:41 AM, Chris Angelico wrote: On Mon, Jan 20, 2014 at 4:50 AM, Ethan Furman et...@stoneleaf.us wrote: The difference I was thinking of is: %h % 3.14 # this works vs. hex(3.14) # this raises In 3.5 both will raise. Now you have me *thoroughly* intrigued. It's not %h (incomplete format - h is a modifier), nor %H (unsupported format character). Do you mean %x? As of 3.4.0b2, that happily truncates a float: %x % 3.14 '3' Is that changing in 3.5? Seems a relatively insignificant point, tbh! Argh. Yes, %x or %X. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sunday 19 January 2014 15:11:52 Larry Martell did opine: On Sun, Jan 19, 2014 at 12:17 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 19/01/2014 18:15, Grant Edwards wrote: On 2014-01-19, Mark Lawrence breamore...@yahoo.co.uk wrote: Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. Fair enough, but what do you do to pass the time _during_ Snooker being shown on TV? I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. Just no comparison, darts and snooker. This is excellent though http://www.youtube.com/watch?v=sHnBppccI0o Now that we're way off on the tangent of what some people consider boring and others don't, I'm really looking forward to watching curling in the upcoming Olympics. I have Larry, and the suspense is not good for those with high blood pressure. Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) Genes Web page http://geneslinuxbox.net:6309/gene Required reading: http://culturalslagheap.wordpress.com/2014/01/12/elemental/ I've enjoyed just about as much of this as I can stand. A pen in the hand of this president is far more dangerous than 200 million guns in the hands of law-abiding citizens. -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sunday 19 January 2014 15:08:31 Roy Smith did opine: In article lbh4oc$nqv$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. What's so complicated? points = 501 for dart in throws(): if points - dart == 0 and dart.is_double(): raise YouWin if points - dart 0: continue points -= dart beer.drink() Aren't you missing a fi there, or a next dart? ;-) Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) Genes Web page http://geneslinuxbox.net:6309/gene Required reading: http://culturalslagheap.wordpress.com/2014/01/12/elemental/ Baseball is a skilled game. It's America's game - it, and high taxes. -- The Best of Will Rogers A pen in the hand of this president is far more dangerous than 200 million guns in the hands of law-abiding citizens. -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sun, Jan 19, 2014 at 1:12 PM, Gene Heskett ghesk...@wdtv.com wrote: On Sunday 19 January 2014 15:11:52 Larry Martell did opine: On Sun, Jan 19, 2014 at 12:17 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 19/01/2014 18:15, Grant Edwards wrote: On 2014-01-19, Mark Lawrence breamore...@yahoo.co.uk wrote: Actually, to go off at a tangent, I'm just getting into GUIs via wxPython. I've discovered there are distinct advantages having to write endless lines of code just to get a piece of data. For example on a Sunday it helps pass the time between the two sessions of the Masters Snooker final being shown on TV. Fair enough, but what do you do to pass the time _during_ Snooker being shown on TV? I can still remember the point in my first trip to the UK when I accidentally stumbled across darts on TV. Given the endless variety (and quantity) of pointless crap that people watch here in the US, I can't really explain why I was so baffled and amused by darts on TV -- but I was. Just no comparison, darts and snooker. This is excellent though http://www.youtube.com/watch?v=sHnBppccI0o Now that we're way off on the tangent of what some people consider boring and others don't, I'm really looking forward to watching curling in the upcoming Olympics. I have Larry, and the suspense is not good for those with high blood pressure. Then don't watch the women: http://oglympics.com/2010/02/16/women-of-curling-fire-on-ice/ -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 18/01/2014 18:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Not me personally. I guess raw_input must have been used somewhere at some time for something, or it would have been scrapped in Python 3, not renamed to input. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 01/18/2014 10:30 AM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Yes - routinely. Emile -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? I use it for pointless throwaway tools, sometimes via the cmd module, sometimes directly. I like that you can add tab-completion. -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On 1/18/2014 1:30 PM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Homework problems (and 'toy' programs, such as hangman), whether in a programming class or elsewhere, are one of the intended use cases of Python. How else would you get interactive input without the complexity of a gui? -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sun, Jan 19, 2014 at 8:33 AM, Terry Reedy tjre...@udel.edu wrote: On 1/18/2014 1:30 PM, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Homework problems (and 'toy' programs, such as hangman), whether in a programming class or elsewhere, are one of the intended use cases of Python. How else would you get interactive input without the complexity of a gui? With the network :) I've written plenty of programs whose sole interaction is via sockets (telnet, HTTP, SMTP, whatever), or a database, or somesuch. But I've also written my share of interactive programs that use the console. Plenty of programs don't need the fanciness of a GUI, but need to prompt the user for stuff. If I write something for my brother (and only him), I'm inclined to spend less effort on the UI than I would for something of wide distribution, and console I/O is approximately zero effort. BTW, I'm assuming your mention of input()/raw_input() is covering Py3 and Py2, respectively. I have *never* used input() in live Py2 code, and never intend to. It's way too subtle. On those really rare occasions when you actually want to take something from the user and immediately eval it, the extra keystrokes for eval(raw_input()) are, IMO, a small price for the clarity. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sunday, January 19, 2014 12:00:20 AM UTC+5:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Similar 'cynicism' regarding print would be salutary for producing better programmers [If youve taught programming and had to deal with code strewn with prints...] -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sun, Jan 19, 2014 at 3:15 PM, Rustom Mody rustompm...@gmail.com wrote: On Sunday, January 19, 2014 12:00:20 AM UTC+5:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Similar 'cynicism' regarding print would be salutary for producing better programmers [If youve taught programming and had to deal with code strewn with prints...] Why, exactly? How ought a program to produce filterable output? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sunday, January 19, 2014 9:51:36 AM UTC+5:30, Chris Angelico wrote: On Sun, Jan 19, 2014 at 3:15 PM, Rustom Mody wrote: On Sunday, January 19, 2014 12:00:20 AM UTC+5:30, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Similar 'cynicism' regarding print would be salutary for producing better programmers [If youve taught programming and had to deal with code strewn with prints...] Why, exactly? How ought a program to produce filterable output? Because these two pieces of code def foo(x): print x+1 def bar(x): return x+1 look identical (to a beginner at least) foo(3) 4 bar(3) 4 And so if they see prints used cavalierly for demo purposes, they think the prints are also ok for production. As a professional programmer, you would of course understand - 'normal' code that does some processing and then some output should not have prints in the processing - web-serving (type of) code that has little other than heavy-duty printing should probably use a template engine of some sort In any case prints all over is a code-smell exacerbated by the way that manuals/examples need to be written -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sun, Jan 19, 2014 at 3:43 PM, Rustom Mody rustompm...@gmail.com wrote: Because these two pieces of code def foo(x): print x+1 def bar(x): return x+1 look identical (to a beginner at least) foo(3) 4 bar(3) 4 As do these pieces of code: def quux(x): return str(x+1) def quux(x): return hex(x+1)[2:] But we don't decry hex or str because of it. Every function has its use and purpose. If someone uses the wrong tool for the job, s/he will have to figure that out at some point - it doesn't mean the tool is wrong. If you're not using the REPL, print is critical. Don't assume everyone uses interactive mode. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: question about input() and/or raw_input()
On Sat, 18 Jan 2014 13:30:20 -0500, Roy Smith wrote: Pardon me for being cynical, but in the entire history of the universe, has anybody ever used input()/raw_input() for anything other than a homework problem? Yes. They are excellent for interactive command line tools. -- Steven -- https://mail.python.org/mailman/listinfo/python-list