The 'is' identity operator checking immutable values caution

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wxPythoner@gmail.com

    The 'is' identity operator checking immutable values caution

    We have to avoid the use of the 'is' identity operator with basic,
    immutable values such as numbers and strings. The result is
    unpredictable because of the way Python handles these objects
    internally.

    How is with this issue in Python 3.0? Is it fixed? Does Python handle
    this things properly now?
  • castironpi@gmail.com

    #2
    Re: The 'is' identity operator checking immutable values caution

    On May 13, 5:10 am, wxPytho...@gmai l.com wrote:
    We have to avoid the use of the 'is' identity operator with basic,
    immutable values such as numbers and strings. The result is
    unpredictable because of the way Python handles these objects
    internally.
    >
    How is with this issue in Python 3.0? Is it fixed? Does Python handle
    this things properly now?
    Ooo. Timing. Good one. <joins rip on 3.0>

    Writer's other wanderings bring Microsoft Research. Who talks to that
    on a daily basis?

    Comment

    • Marco Mariani

      #3
      Re: The 'is' identity operator checking immutable values caution

      wxPythoner@gmai l.com wrote:
      We have to avoid the use of the 'is' identity operator with basic,
      immutable values such as numbers and strings.
      I'm glad for you. Did you really write checks like "if foo is 27" ?

      The point is, you have to learn technologies to use them. It's not like
      technologies learn you (not even in soviet Russia)
      How is with this issue in Python 3.0? Is it fixed?
      There is nothing to fix.
      Does Python handle this things properly now?
      It always did.

      Comment

      • Christian Heimes

        #4
        Re: The 'is' identity operator checking immutable values caution

        wxPythoner@gmai l.com schrieb:
        We have to avoid the use of the 'is' identity operator with basic,
        immutable values such as numbers and strings. The result is
        unpredictable because of the way Python handles these objects
        internally.
        You are confusing immutable objects with singletons. Never use "is" with
        strings and numbers.

        Christian

        Comment

        • castironpi@gmail.com

          #5
          Re: The 'is' identity operator checking immutable values caution

          On May 13, 5:37 am, Christian Heimes <li...@cheimes. dewrote:
          wxPytho...@gmai l.com schrieb:
          >
          We have to avoid the use of the 'is' identity operator with basic,
          immutable values such as numbers and strings. The result is
          unpredictable because of the way Python handles these objects
          internally.
          >
          You are confusing immutable objects with singletons. Never use "is" with
          strings and numbers.
          >
          Christian
          I was back on 'handle'. Handle internally, handle right. Gotta be 6
          a.m.

          Comment

          • Bruno Desthuilliers

            #6
            Re: The 'is' identity operator checking immutable values caution

            wxPythoner@gmai l.com a écrit :
            We have to avoid the use of the 'is' identity operator with basic,
            immutable values such as numbers and strings. The result is
            unpredictable because of the way Python handles these objects
            internally.
            >
            How is with this issue in Python 3.0? Is it fixed? Does Python handle
            this things properly now?
            This is not an issue and is already properly handled. Don't use identity
            test when you want an equality test, period.

            Comment

            Working...