Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105753 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2016-03-26 23:05 +1100 |
| Last post | 2016-03-26 23:05 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to make Python interpreter a little more strict? Chris Angelico <rosuav@gmail.com> - 2016-03-26 23:05 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-03-26 23:05 +1100 |
| Subject | Re: How to make Python interpreter a little more strict? |
| Message-ID | <mailman.35.1458993946.28225.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web