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

2016-03-27 Thread Steven D'Aprano
On Mon, 28 Mar 2016 07:49 am, BartC wrote: > On 27/03/2016 21:32, Tim Chase wrote: >> On 2016-03-27 14:28, Steven D'Aprano wrote: > >>> 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

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

2016-03-27 Thread Nobody
On Sat, 26 Mar 2016 23:30:30 +, John Pote wrote: > So I have sympathy with the OP, I would expect the compiler to pick this > up Why? The code is valid, the compiler knows how to generate the appropriate bytecode for it. The compiler isn't "lint". Reporting code which is actually invalid is

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

2016-03-27 Thread Chris Angelico
On Mon, Mar 28, 2016 at 7:49 AM, BartC wrote: > On 27/03/2016 21:32, Tim Chase wrote: >> >> On 2016-03-27 14:28, Steven D'Aprano wrote: > > >>> 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", sin

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

2016-03-27 Thread BartC
On 27/03/2016 21:32, Tim Chase wrote: On 2016-03-27 14:28, Steven D'Aprano wrote: 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, bu

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

2016-03-27 Thread Tim Chase
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 > > >

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

2016-03-26 Thread Steven D'Aprano
On Sun, 27 Mar 2016 10:30 am, John Pote 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 r

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

2016-03-26 Thread BartC
On 26/03/2016 23:30, John Pote 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 A couple of

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

2016-03-26 Thread John Pote
On 26/03/2016 12:05, Chris Angelico wrote: On Fri, Mar 25, 2016 at 11:06 PM, Aleksander Alekseev 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(

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

2016-03-26 Thread Chris Angelico
On Fri, Mar 25, 2016 at 11:06 PM, Aleksander Alekseev 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

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

2016-03-26 Thread Steven D'Aprano
On Fri, 25 Mar 2016 11:06 pm, Aleksander Alekseev wrote: > Is it possible to make python complain in this case? Or maybe solve > such an issue somehow else? This is a job for a "linter", such as pychecker, pylint or pyflakes. Google for more if you are interested. A linter will check your code f

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

2016-03-26 Thread Mark Lawrence
On 25/03/2016 12:06, Aleksander Alekseev wrote: 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

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

2016-03-26 Thread Chris Warrick
On 25 March 2016 at 13:06, Aleksander Alekseev wrote: > 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$

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

2016-03-26 Thread Nick Sarbicki
On Sat, Mar 26, 2016 at 9:59 AM Aleksander Alekseev wrote: > 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:~/

How to make Python interpreter a little more strict?

2016-03-26 Thread Aleksander Alekseev
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 m