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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Thu, Nov 17, 2011 at 6:18 PM, John Ladasky wrote: > Hi folks, > > I'm trying to write tidy, modular code which includes a long-running proc= ess. =C2=A0From time to time I MIGHT like to check in on the progress being= made by that long-running process, in various ways. =C2=A0Other times, I'l= l just want to let it run. =C2=A0So I have a section of code which, general= ly, looks like this: > > def _pass(*args): > =C2=A0 =C2=A0pass > > def long_running_process(arg1, arg2, arg_etc, report =3D _pass): > =C2=A0 =C2=A0result1 =3D do_stuff() > =C2=A0 =C2=A0report(result1) > =C2=A0 =C2=A0result2 =3D do_some_different_stuff() > =C2=A0 =C2=A0report(result2) > =C2=A0 =C2=A0result3 =3D do_even_more_stuff() > =C2=A0 =C2=A0report(result3) > =C2=A0 =C2=A0return result3 > > This does what I want. =C2=A0When I do not specify a report function, the= process simply runs. =C2=A0Typically, 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, particular= ly 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? =C2=A0I played= with the interpreter a bit. > > IDLE 2.6.6 =C2=A0 =C2=A0 =C2=A0=3D=3D=3D=3D No Subprocess =3D=3D=3D=3D >>>> pass >>>> pass() > SyntaxError: invalid syntax >>>> type(pass) > SyntaxError: invalid syntax > > So, pass does not appear to be a function, nor even an object. =C2=A0Is i= t 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