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


Groups > comp.lang.python > #105753

Re: How to make Python interpreter a little more strict?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: How to make Python interpreter a little more strict?
Date Sat, 26 Mar 2016 23:05:38 +1100
Lines 32
Message-ID <mailman.35.1458993946.28225.python-list@python.org> (permalink)
References <20160325150608.21c3827a@fujitsu>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de A/BeczMUpRSX2clmA00F4Ar6i0sNDzKmuT7AX0p14uig==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.05; 'python3': 0.05; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'bug': 0.10; 'python': 0.10; 'interpreter': 0.15; '(free': 0.16; '2016': 0.16; 'evaluating': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:make': 0.16; 'wrote:': 0.16; 'detect': 0.18; 'typing': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'code.': 0.23; 'this:': 0.23; 'header :In-Reply-To:1': 0.24; 'fri,': 0.27; 'skip:# 10': 0.27; 'message- id:@mail.gmail.com': 0.27; 'cat': 0.29; 'complain': 0.29; 'editors': 0.29; 'code': 0.30; 'window': 0.30; 'maybe': 0.33; 'received:google.com': 0.35; 'next': 0.35; 'could': 0.35; 'nothing.': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'received:209.85.213': 0.37; 'doing': 0.38; 'received:209': 0.38; 'end': 0.39; 'where': 0.40; 'some': 0.40; 'save': 0.60; 'your': 0.60; 'subject:more': 0.61; 'mar': 0.65; 'here': 0.66; 'spend': 0.67; 'hour': 0.69; 'case?': 0.84; 'chrisa': 0.84; 'tie': 0.84; 'to:none': 0.91; 'that),': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=9J8M6onWjRSoNKdXo34ytcNf2/B3DobKORO5kvcMwwI=; b=jSv2PwNayUyHZpObBVPz8egJKDWeYKjwd0u22JvxMXszEdGu5zfvMHpNlJ2Ta8Tv7I Xxo9FfINOZ7UvR+lpsfa6Q+HGrMJLVGNjDs5VimOolA4UGxKXA/vfmegm1N81S5KJsIq e5ur1fca+V9xPxmKBbTFxa9GH/F1I1vbUZ9VQ0x4TfLBHb6H2uSNh0cDCvb8/FYB/dYw 95te4nNpfSQggBlJfExP1GRSLtwT6XHQDXJvb9HS4UhXFn1xu/x6GxwbISvEjQJArin8 kSe3f4c+/XOjpLRVWEUNBnEGW/7dvkVatPlznCt39e40QWYTXxqj9jSZNmKLEtcvsxNV hI/g==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=9J8M6onWjRSoNKdXo34ytcNf2/B3DobKORO5kvcMwwI=; b=FRvHu1TNez7S1a4LzJGRCnw1kUGcDfELmfe/p9gL1jFOkis4j1tRLKKJCYrdxIvr07 JL26bGTj5XpIGPeV9/WZbBkp7M8mFYfd/xl+YLH+YRhl4fQdkL6E96L8bJkI+OUq3dTm mORB9HmPfK1I7+53BFrR4RCrfToHbXrvHJJz5jwNZrd4cvT7RQLoQ17y1F5eS41fUBI+ sw3ci9Y9rdE7dWsUNDjZRxtbBJSV5/aOkLXTI1tgRWRZ8s+zZH2P7rREe7ELOuMyZ+4x Eg4SLckp7LTOa058gMfoR8nf4QjUQDGn5vlhE7wKAYQZ4GJJby9iNQbKcYQd1s2fLAZZ 520A==
X-Gm-Message-State AD7BkJKbhxd2rTRWjwlYeAQwGX5RuGrdnSsibvQlrUxDwAHJYjz24yAS78Hd6RBGclKR6NnPs4HxEgyx8Db8yQ==
X-Received by 10.51.17.34 with SMTP id gb2mr1200956igd.13.1458993938662; Sat, 26 Mar 2016 05:05:38 -0700 (PDT)
In-Reply-To <20160325150608.21c3827a@fujitsu>
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:105753

Show key headers only | View raw


On Fri, Mar 25, 2016 at 11:06 PM, Aleksander Alekseev <afiskon@devzen.ru> wrote:
> 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?

I think what you're looking for here is an acknowledgement that
evaluating the name "next" accomplishes nothing. That's not really
something the Python interpreter should be looking at (hey, you might
have good reason for doing that), but there are linters that can
detect this kind of dead code. Some of them tie into programmer's
editors, so you could get a nice little warning message right in the
window where you're typing your code. Look into some of the top-end
editors (free or commercial) and see what you think of them - they can
save you no end of time.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How to make Python interpreter a little more strict? Chris Angelico <rosuav@gmail.com> - 2016-03-26 23:05 +1100

csiph-web