Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77549
| References | (1 earlier) <51acfec6-6b7b-4773-8d70-0360381bbed1@googlegroups.com> <mailman.13751.1409795794.18130.python-list@python.org> <612dd9e6-653b-4e07-aebe-ffd31eec2a9e@googlegroups.com> <mailman.13755.1409797551.18130.python-list@python.org> <54086853$0$6574$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2014-09-04 23:55 +1000 |
| Subject | Re: Python is going to be hard |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13768.1409838951.18130.python-list@python.org> (permalink) |
On Thu, Sep 4, 2014 at 11:25 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > Of course console output is > often useful, but it is slightly smelly: > > - beginners have a tendency to use print when they should be using > return, and consequently can't easily chain functions together; > > - languages like shell scripting languages, which are designed to > chain such printing functions together, suffer because of it: > > Think of how many broken bash scripts there are out there which assume that > files names can never contain newlines. Or, for that matter, spaces. Focusing everything on output, yes that's a problem. (Look at the ob_* functions in PHP - they are an abomination built to cope with other abominations.) > Even in Python, consider how limiting something like dis.dis() is, seeing > how it prints its output instead of returning it. I agree that it's limited - but how would you do it differently? Python's repr for multiline text is pretty unreadable. The only way I could imagine it being done is if it returns a custom object whose repr is the text we usually see. If you want to send it somewhere other than the console. dis.dis(file=...) works; and if you want to do something other than simple output, you probably want one of the lower-level functions (which I haven't personally dug into, but I'm thinking get_instructions is probably more useful than dis for more complicated jobs). >> Anyway, all you're doing is relying on the magic of interactive mode >> to call repr() and print() for you. > > Well, yes, but isn't that the point? Let your tools do most of the work. Sure, but if you hate something enough to scream "NO PRINT" at us, isn't it a bit odd to advocate something that does the exact same thing only hidden? Why is it somehow okay to rely on the side effect of intermediate expression results getting printed, while decrying side effects anywhere else? >>> The interpreter-REPL is less reliable than a script? >> >> When you start a script, you have a consistent environment - an empty >> one. When you write a series of commands in the interactive >> interpreter, the environment for each one depends on all the preceding >> commands. So when you have a problem, you might have to copy and paste >> the entire interpreter session, rather than just the one command. > > True, but the same applies to a script. If you have a problem with line 100, > you can't just post line 100, you may have to post the entire 100 lines > before it. Being able to isolate the problem to the minimal amount of code > needed to demonstrate it is an important skill for all developers. Yes, that's true. But a dozen-line script that's been through a dozen iterations of editing is still a dozen lines of script, whereas it might be sixty or seventy lines of interactive output. It's generally easier to "isolate to the minimum" when you start with something that's inherently shorter. It's also easier to isolate to the minimum when you work with a consistent starting position, rather than have each one build on the preceding ones. Like I said in my most recent response to Rustom, we probably don't disagree nearly as much as it seemed at the first couple of responses. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:10 -0400
Re: Python is going to be hard John Gordon <gordon@panix.com> - 2014-09-03 18:17 +0000
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:52 -0400
Re: Python is going to be hard mm0fmf <none@mailinator.com> - 2014-09-03 22:37 +0100
Re: Python is going to be hard Rock Neurotiko <miguelglafuente@gmail.com> - 2014-09-03 20:16 +0200
Re: Python is going to be hard Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-09-03 11:19 -0700
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:50 -0400
Re: Python is going to be hard MRAB <python@mrabarnett.plus.com> - 2014-09-03 19:24 +0100
Re: Python is going to be hard Skip Montanaro <skip@pobox.com> - 2014-09-03 13:28 -0500
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:52 -0400
Re: Python is going to be hard Ethan Furman <ethan@stoneleaf.us> - 2014-09-03 11:33 -0700
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:41 -0400
Re: Python is going to be hard Ethan Furman <ethan@stoneleaf.us> - 2014-09-03 12:49 -0700
Re: Python is going to be hard Juan Christian <juan0christian@gmail.com> - 2014-09-03 15:44 -0300
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:56 -0400
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 14:49 -0400
Re: Python is going to be hard Ethan Furman <ethan@stoneleaf.us> - 2014-09-03 11:55 -0700
Re: Python is going to be hard Rob Gaddi <rgaddi@technologyhighland.invalid> - 2014-09-03 12:01 -0700
Re: Python is going to be hard Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-03 13:11 -0600
Re: Python is going to be hard Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-03 15:22 -0400
Re: Python is going to be hard Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-04 12:11 +1000
Re: Python is going to be hard Denis McMahon <denismfmcmahon@gmail.com> - 2014-09-03 20:55 +0000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 18:48 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 11:56 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 19:10 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 12:25 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 19:33 -0700
Re: Python is going to be hard alister <alister.nospam.ware@ntlworld.com> - 2014-09-04 10:29 +0000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-04 06:08 -0700
Re: Python is going to be hard Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-04 23:25 +1000
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 23:55 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 20:22 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 13:49 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 21:11 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 15:02 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 23:23 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 16:39 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-04 06:15 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-04 23:30 +1000
Re: Python is going to be hard Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-04 23:37 +1000
Re: Python is going to be hard Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-09-04 15:04 +0100
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-05 00:08 +1000
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-04 19:24 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-05 12:30 +1000
Re: Python is going to be hard Roy Smith <roy@panix.com> - 2014-09-04 22:51 -0400
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-04 19:56 -0700
Re: Python is going to be hard Chris Angelico <rosuav@gmail.com> - 2014-09-05 13:08 +1000
Re: Python is going to be hard Ethan Furman <ethan@stoneleaf.us> - 2014-09-03 21:06 -0700
Re: Python is going to be hard Rustom Mody <rustompmody@gmail.com> - 2014-09-03 21:15 -0700
csiph-web