Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105782
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to make Python interpreter a little more strict? |
| Date | Sat, 26 Mar 2016 14:02:48 -0400 |
| Organization | IISS Elusive Unicorn |
| Lines | 66 |
| Message-ID | <mailman.54.1459015336.28225.python-list@python.org> (permalink) |
| References | <20160325150608.21c3827a@fujitsu> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de RbBog0kH0QDXsZnjoKX5iw/SLOnwhC2pYovigLrgOcHw== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.05; 'python3': 0.05; 'subject:How': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'typeerror:': 0.09; 'window?': 0.09; 'bug': 0.10; 'python': 0.10; '2.7': 0.13; '(note:': 0.16; '2016': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'skip:> 20': 0.16; 'subject:make': 0.16; 'url:home': 0.18; '>>>': 0.20; '"",': 0.22; 'trying': 0.22; 'this:': 0.23; '(most': 0.24; "doesn't": 0.26; 'header:X -Complaints-To:1': 0.26; 'fri,': 0.27; 'least': 0.27; 'arguments,': 0.29; 'cat': 0.29; 'complain': 0.29; 'print': 0.30; 'code': 0.30; 'maybe': 0.33; 'traceback': 0.33; 'file': 0.34; 'next': 0.35; 'skip:> 10': 0.35; 'expected': 0.35; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'to:addr:python.org': 0.40; 'still': 0.40; 'subject:more': 0.61; 'mar': 0.65; 'spend': 0.67; 'hour': 0.69; 'case?': 0.84; 'dennis': 0.91; 'received:108': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | adsl-108-73-117-233.dsl.klmzmi.sbcglobal.net |
| X-Newsreader | Forte Agent 6.00/32.1186 |
| X-No-Archive | YES |
| 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:105782 |
Show key headers only | View raw
On Fri, 25 Mar 2016 15:06:08 +0300, Aleksander Alekseev <afiskon@devzen.ru>
declaimed the following:
>Hello
>
>Recently I spend half an hour looking for a bug in code like this:
>
>eax@fujitsu:~/temp$ cat ./t.py
>#!/usr/bin/env python3
>
>for x in range(0,5):
> if x % 2 == 0:
> next
> print(str(x))
>
>eax@fujitsu:~/temp$ ./t.py
>0
>1
>2
>3
>4
>
>Is it possible to make python complain in this case? Or maybe solve
>such an issue somehow else?
By trying it out in the interactive window? (Note: Python 2.7 -- though
Python 3 doesn't need the "str(x)" either -- print will still ask for the
printable form of x.
>>> for x in range(0,5):
... if (x % 2) == 0:
... next
... print x
...
<built-in function next>
0
1
<built-in function next>
2
3
<built-in function next>
4
>>>
>>> for x in range(0,5):
... if (x % 2) == 0:
... next()
... print x
...
Traceback (most recent call last):
File "<interactive input>", line 3, in <module>
TypeError: next expected at least 1 arguments, got 0
>>>
>>> for x in range(0,5):
... if (x % 2) == 0:
... continue
... print x
...
1
3
>>>
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to make Python interpreter a little more strict? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-26 14:02 -0400
csiph-web