Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: [Python-ideas] Make "is" checks on non-singleton literals errors

Reply
Thread Tools

Re: [Python-ideas] Make "is" checks on non-singleton literals errors

 
 
Chris Angelico
Guest
Posts: n/a
 
      10-09-2012
On Tue, Oct 9, 2012 at 1:14 PM, Guido van Rossum <> wrote:
> Maybe we should do something more drastic and always create a new,
> unique constant whenever a literal occurs as an argument of 'is' or
> 'is not'? Then such code would never work, leading people to examine
> their code more closely. I betcha we have people who could change the
> bytecode compiler easily enough to do that. (I'm not seriously
> proposing this, except as a threat of what we could do if the
> SyntaxWarning is rejected.


That wouldn't guarantee that the code would never work, merely that
the 'is' checks would be never true. Dangerous if the condition is a
guard for an unusual condition. A unit test could of course catch it,
but that assumes that everyone who writes "if x is 0" has tests
probing both branches of that check...

ChrisA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
program that checks a c source for syntax errors Ceriousmall C Programming 4 07-14-2011 02:44 PM
Java: byte literals and short literals John Goche Java 8 01-17-2006 11:12 PM
Changing order Thunderbird checks email fety Firefox 1 04-10-2005 10:33 AM
"Pattern" or "best practice" in security checks Anders K. Jacobsen [DK] ASP .Net 1 12-06-2004 03:46 AM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57