Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15850

Re: What exactly is "pass"? What should it be?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'interpreter': 0.05; 'function,': 0.07; '(good': 0.09; '>>>>': 0.09; 'argument,': 0.09; 'folks,': 0.09; 'run.': 0.09; 'subprocess': 0.09; 'def': 0.14; 'argument': 0.15; 'cc:addr:python-list': 0.15; 'syntax': 0.15; 'this:': 0.15; 'arg2,': 0.16; 'bit.': 0.16; 'runs.': 0.16; 'subject:pass': 0.16; 'syntaxerror:': 0.16; '\xc2\xa0i': 0.16; 'cheers,': 0.18; 'wrote:': 0.18; 'example.': 0.18; 'seems': 0.19; 'trying': 0.21; 'cc:no real name:2**0': 0.21; 'process,': 0.21; 'appear': 0.23; 'header:In-Reply-To:1': 0.23; 'specify': 0.24; 'times,': 0.24; 'cc:2**0': 0.25; 'code': 0.25; 'fine': 0.26; "i'm": 0.26; 'function': 0.27; 'received:209.85.220': 0.27; 'invalid': 0.28; 'pass': 0.28; 'idle': 0.28; 'looks': 0.28; 'cc:addr:python.org': 0.29; 'message-id:@mail.gmail.com': 0.29; 'print': 0.29; 'but...': 0.30; 'object.': 0.30; 'chris': 0.30; 'subject:?': 0.31; "i'll": 0.31; 'nov': 0.31; 'pm,': 0.31; 'thu,': 0.32; 'does': 0.32; 'instead': 0.33; '17,': 0.34; 'null': 0.34; 'pass.': 0.34; 'subject:What': 0.34; 'which,': 0.34; 'object': 0.35; 'url:python': 0.35; 'something': 0.36; 'list,': 0.37; 'but': 0.37; 'question,': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; 'url:docs': 0.38; 'define': 0.39; 'progress': 0.39; 'subject:: ': 0.39; 'might': 0.39; 'skip:_ 10': 0.40; 'received:209': 0.40; 'being': 0.40; 'skip:l 20': 0.40; 'more': 0.60; 'your': 0.61; 'john': 0.62; '2011': 0.62; 'accepts': 0.64; 'ever': 0.65; 'supply': 0.68; 'skip:\xc2 10': 0.73; 'sender:addr:chris': 0.84; 'subject:should': 0.84; 'url:reference': 0.84; 'to:none': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type :content-transfer-encoding; bh=Ac/R6JylaUcIs14ndADIdYc1Zb/m4aL7bni7bft+xYs=; b=THk67IA1csFwftrKlaZsY7A8Q00ZcDuiFvG7cC0kUTx05nfXK0qrfYTShRn1m4fzl7 ssdc6xLj2ptAy8beL2r2htDeX6ioukviuIB8/wz13wZMHAIx5FHnt712t9EIp+4DlJI0 z6qK+OBz2AsZaUaZ8ZfyK9RDvZtakhOJR6oUg=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37>
References <27955957.352.1321582691251.JavaMail.geo-discussion-forums@prap37>
Date Thu, 17 Nov 2011 18:45:58 -0800
X-Google-Sender-Auth 8KJbjQ4k49CAHqpoVnT1STQG7fo
Subject Re: What exactly is "pass"? What should it be?
From Chris Rebert <clp2@rebertia.com>
Cc python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2813.1321584361.27778.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1321584361 news.xs4all.nl 6990 [2001:888:2000:d::a6]:58350
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15850

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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