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

Discussion in 'Python' started by Chris Angelico, Oct 9, 2012.

  1. 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
     
    Chris Angelico, Oct 9, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Goche
    Replies:
    8
    Views:
    16,578
  2. Proton Projects - Moin

    Singleton - Whether Cloneable overrides Singleton

    Proton Projects - Moin, Mar 26, 2007, in forum: Java
    Replies:
    4
    Views:
    3,335
    Proton Projects - Moin
    Mar 27, 2007
  3. Ceriousmall

    program that checks a c source for syntax errors

    Ceriousmall, Jul 12, 2011, in forum: C Programming
    Replies:
    4
    Views:
    1,296
    Ceriousmall
    Jul 14, 2011
  4. Wilhelm
    Replies:
    1
    Views:
    186
  5. Trans
    Replies:
    12
    Views:
    304
    Robert Klemme
    Sep 14, 2007
Loading...

Share This Page