Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15850
| References | <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37> |
|---|---|
| Date | 2011-11-17 18:45 -0800 |
| Subject | Re: What exactly is "pass"? What should it be? |
| From | Chris Rebert <clp2@rebertia.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2813.1321584361.27778.python-list@python.org> (permalink) |
On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky <ladasky@my-deja.com> wrote: > Hi folks, > > I'm trying to write tidy, modular code which includes a long-running process. From time to time I MIGHT like to check in on the progress being made by that long-running process, in various ways. Other times, I'll just want to let it run. So I have a section of code which, generally, looks like this: > > def _pass(*args): > pass > > def long_running_process(arg1, arg2, arg_etc, report = _pass): > result1 = do_stuff() > report(result1) > result2 = do_some_different_stuff() > report(result2) > result3 = do_even_more_stuff() > report(result3) > return result3 > > This does what I want. When I do not specify a report function, the process simply runs. Typically, when I do supply a report function, it would print something to stdout, or draw an update through a GUI. > > But this approach seems a tad cumbersome and unPythonic to me, particularly the part where I define the function _pass() which accepts an arbitrary argument list, and does nothing but... pass. Seems fine to me (good use of the null object pattern), although I might define _pass() to instead take exactly 1 argument, since that's all you ever call report() with in your example. > This has led me to ask the question, what exactly IS pass? I played with the interpreter a bit. > > IDLE 2.6.6 ==== No Subprocess ==== >>>> pass >>>> pass() > SyntaxError: invalid syntax >>>> type(pass) > SyntaxError: invalid syntax > > So, pass does not appear to be a function, nor even an object. Is it nothing more than a key word? Correct: http://docs.python.org/reference/simple_stmts.html#pass http://docs.python.org/reference/lexical_analysis.html#keywords Cheers, Chris
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What exactly is "pass"? What should it be? John Ladasky <ladasky@my-deja.com> - 2011-11-17 18:18 -0800
Re: What exactly is "pass"? What should it be? Chris Rebert <clp2@rebertia.com> - 2011-11-17 18:45 -0800
Re: What exactly is "pass"? What should it be? John Ladasky <ladasky@my-deja.com> - 2011-11-17 21:03 -0800
Re: What exactly is "pass"? What should it be? John Ladasky <ladasky@my-deja.com> - 2011-11-17 21:03 -0800
Re: What exactly is "pass"? What should it be? Chris Angelico <rosuav@gmail.com> - 2011-11-18 13:59 +1100
Re: What exactly is "pass"? What should it be? alex23 <wuwei23@gmail.com> - 2011-11-17 22:04 -0800
Re: What exactly is "pass"? What should it be? Dominic Binks <dbinks@codeaurora.org> - 2011-11-17 19:01 -0800
Re: What exactly is "pass"? What should it be? Ben Finney <ben+python@benfinney.id.au> - 2011-11-18 14:45 +1100
Re: What exactly is "pass"? What should it be? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-11-17 20:34 -0800
Re: What exactly is "pass"? What should it be? John Ladasky <ladasky@my-deja.com> - 2011-11-17 21:07 -0800
Re: What exactly is "pass"? What should it be? Chris Angelico <rosuav@gmail.com> - 2011-11-18 16:34 +1100
Re: What exactly is "pass"? What should it be? Chris Rebert <clp2@rebertia.com> - 2011-11-17 21:49 -0800
Re: What exactly is "pass"? What should it be? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-18 06:07 +0000
Re: What exactly is "pass"? What should it be? John Ladasky <ladasky@my-deja.com> - 2011-11-17 21:07 -0800
Re: What exactly is "pass"? What should it be? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-11-18 10:57 +0100
Re: What exactly is "pass"? What should it be? MRAB <python@mrabarnett.plus.com> - 2011-11-18 13:03 +0000
csiph-web