Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105872
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to make Python interpreter a little more strict? |
| Date | Sun, 27 Mar 2016 15:32:36 -0500 |
| Lines | 36 |
| Message-ID | <mailman.94.1459110963.28225.python-list@python.org> (permalink) |
| References | <20160325150608.21c3827a@fujitsu> <CAPTjJmqYuzLRGX6x6w5hpWQaB4UJ+-Dy=RXgotUxT-CO6rjYXA@mail.gmail.com> <mailman.67.1459037003.28225.python-list@python.org> <56f7536b$0$22140$c3e8da3$5496439d@news.astraweb.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de vzyoZ1HrsuAP1OyOhG7FaAYBYnPFpu4+Nkm/SgLbqQqQ== |
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'exist,': 0.07; 'subject:How': 0.09; 'exist.': 0.09; 'nameerror:': 0.09; 'def': 0.13; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'nameerror': 0.16; 'received:10.122': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:make': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'parameter': 0.22; 'tried': 0.24; 'header:In-Reply- To:1': 0.24; "i've": 0.25; "doesn't": 0.26; 'question': 0.27; 'function': 0.28; 'raise': 0.29; 'print': 0.30; 'code': 0.30; "d'aprano": 0.33; 'steven': 0.33; 'similar': 0.33; 'case,': 0.34; 'except': 0.34; 'next': 0.35; 'fail': 0.35; 'quite': 0.35; 'but': 0.36; 'lines': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'charset:us-ascii': 0.37; '(with': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'some': 0.40; 'subject:more': 0.61; "they're": 0.66; 'useful.': 0.72; 'intrigued': 0.84; 'received:23': 0.84 |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-MC-Relay | Neutral |
| X-MailChannels-SenderId | wwwh|x-authuser|tim@thechases.com |
| X-MailChannels-Auth-Id | wwwh |
| X-MC-Loop-Signature | 1459110967231:2708064406 |
| X-MC-Ingress-Time | 1459110967231 |
| In-Reply-To | <56f7536b$0$22140$c3e8da3$5496439d@news.astraweb.com> |
| X-Mailer | Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) |
| X-AuthUser | tim@thechases.com |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105872 |
Show key headers only | View raw
On 2016-03-27 14:28, Steven D'Aprano wrote:
> > So intrigued by this question I tried the following
> > def fnc( n ):
> > print "fnc called with parameter '%d'" % n
> > return n
> >
> > for i in range(0,5):
> > if i%2 == 0:
> > fnc
> > next
> > print i
> >
> > and got the same result as the OP
>
> In this case, the two lines "fnc" and "next" simply look up the
> function names, but without actually calling them. They're not
> quite "no-ops", since they can fail and raise NameError if the name
> doesn't exist, but otherwise they might as well be no-ops.
Which is actually useful. I've got some 2.4 code that reads
try:
any
except NameError:
def any(...):
...
(with a similar block for all() )
I don't want to call any() or all(), I simply want to test whether
they exist.
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to make Python interpreter a little more strict? John Pote <johnhpote@o2.co.uk> - 2016-03-26 23:30 +0000
Re: How to make Python interpreter a little more strict? BartC <bc@freeuk.com> - 2016-03-27 00:36 +0000
Re: How to make Python interpreter a little more strict? Steven D'Aprano <steve@pearwood.info> - 2016-03-27 14:28 +1100
Re: How to make Python interpreter a little more strict? Tim Chase <python.list@tim.thechases.com> - 2016-03-27 15:32 -0500
Re: How to make Python interpreter a little more strict? BartC <bc@freeuk.com> - 2016-03-27 21:49 +0100
Re: How to make Python interpreter a little more strict? Chris Angelico <rosuav@gmail.com> - 2016-03-28 07:59 +1100
Re: How to make Python interpreter a little more strict? Steven D'Aprano <steve@pearwood.info> - 2016-03-28 12:24 +1100
Re: How to make Python interpreter a little more strict? Nobody <nobody@nowhere.invalid> - 2016-03-28 00:26 +0100
csiph-web