"0 in [True,False]" returns True

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antoon Pardon

    #46
    Re: "0 in [True,False]" returns True

    Op 2005-12-13, Steve Holden schreef <steve@holdenwe b.com>:[color=blue]
    > Antoon Pardon wrote:[color=green]
    >> Op 2005-12-13, Chris Mellon schreef <arkanes@gmail. com>:[/color]
    > [...][color=green][color=darkred]
    >>>If you have a consistent API and you're checking for error values from
    >>>your GTK functions, then you already have a lot more code than using 2
    >>>varaibles will cost you. 10 lines, maybe.
    >>>
    >>>The fact that you think setting two variables is "too hard" but you're
    >>>perfectly happy with checking for boolean types instead just testing
    >>>truth values I think is a real problem.[/color]
    >>
    >>
    >> These aren't just truth values. If I would have to go split in
    >> meaningfull truth values I would need at least three variables.
    >>
    >>[color=darkred]
    >>>You aren't saving yourself any
    >>>performanc e. You're barely even saving yourself any typing, and you're
    >>>making your code (intentionally, it seems) that much more compllicated
    >>>and hard to understand.[/color]
    >>
    >>
    >> There is nothing complicated or hard to understand.
    >>[/color]
    > Nope, just a messy, hard to maintain misuse of a single variable for
    > multiple purposes.[/color]

    No that variable has just one purpose, noting the state of the tube.
    [color=blue]
    > Perfectly simple, perfectly easy to understand and
    > rather more bug-prone that a straightforward separation of state and
    > other data.[/color]

    What you call other date is IMO just state information.
    [color=blue][color=green]
    >> I find it odd that each time declaration are mentioned people here
    >> react very rejecting and say that one of the features they love
    >> about python is the freedom that a name is not limited to a variable
    >> of one type, while when someone makes use of that freedom labeling
    >> such code as code smell.
    >>[/color]
    > There's a difference between using a single name to refer to values of
    > polymorphic types (which can therefore all be handled by the same code)
    > and using the same name to reference state information in one case (this
    > item has no connected callback) and other data (the callback is to
    > such-and-such an object).
    >[color=green]
    >> But lets make an effort to make the code more readable. What
    >> about the following suggestion. I use a kind of EnumType with
    >> two values: NotRegistered and Registerd. And the name of the
    >> type is NotConnected. So I can then write
    >>
    >> if type(self.callb ack) is NotConnected.
    >>
    >> Would that be selfdocumenting enough for you?
    >>[/color]
    > It would be somewhat more self-documenting, but why not just use one
    > name to indicate the state and another, only meaningful in certain
    > states, to indicate the callback?[/color]

    Why should I do that? Checking the type of a variable is conceptually
    no different form testing set membership. So what I did, was just
    bringing two disjoint sets togther and working with a variable from
    that union. This is all in all a rather simple mathematical idea.
    And I don't see why I should put certain information into a seperate
    variable. It makes as much sense as working with numbers and using
    a seperate variable to store whether a particular number is postive,
    even or has some other characteristic. You don't seperate information
    you can easily acquire from the variable itself. So why should I
    seperate this information that is aquired just as easily?

    --
    Antoon Pardon

    Comment

    • Steve Holden

      #47
      Re: &quot;0 in [True,False]&quot; returns True

      Antoon Pardon wrote:[color=blue]
      > Op 2005-12-13, Steve Holden schreef <steve@holdenwe b.com>:[/color]
      [...][color=blue][color=green]
      >>[color=darkred]
      >>>But lets make an effort to make the code more readable. What
      >>>about the following suggestion. I use a kind of EnumType with
      >>>two values: NotRegistered and Registerd. And the name of the
      >>>type is NotConnected. So I can then write
      >>>
      >>> if type(self.callb ack) is NotConnected.
      >>>
      >>>Would that be selfdocumenting enough for you?
      >>>[/color]
      >>
      >>It would be somewhat more self-documenting, but why not just use one
      >>name to indicate the state and another, only meaningful in certain
      >>states, to indicate the callback?[/color]
      >
      >
      > Why should I do that? Checking the type of a variable is conceptually
      > no different form testing set membership. So what I did, was just
      > bringing two disjoint sets togther and working with a variable from
      > that union. This is all in all a rather simple mathematical idea.
      > And I don't see why I should put certain information into a seperate
      > variable. It makes as much sense as working with numbers and using
      > a seperate variable to store whether a particular number is postive,
      > even or has some other characteristic. You don't seperate information
      > you can easily acquire from the variable itself. So why should I
      > seperate this information that is aquired just as easily?
      >[/color]

      Well, as you might argue, I'm not tryng to effect a change in your
      behaviour, I'm simply trying to point out how it could be made more
      rational.

      regards
      Steve
      --
      Steve Holden +44 150 684 7255 +1 800 494 3119
      Holden Web LLC www.holdenweb.com
      PyCon TX 2006 www.python.org/pycon/

      Comment

      • bonono@gmail.com

        #48
        Re: &quot;0 in [True,False]&quot; returns True


        Steve Holden wrote:[color=blue][color=green][color=darkred]
        > >>It would be somewhat more self-documenting, but why not just use one
        > >>name to indicate the state and another, only meaningful in certain
        > >>states, to indicate the callback?[/color]
        > >
        > >
        > > Why should I do that? Checking the type of a variable is conceptually
        > > no different form testing set membership. So what I did, was just
        > > bringing two disjoint sets togther and working with a variable from
        > > that union. This is all in all a rather simple mathematical idea.
        > > And I don't see why I should put certain information into a seperate
        > > variable. It makes as much sense as working with numbers and using
        > > a seperate variable to store whether a particular number is postive,
        > > even or has some other characteristic. You don't seperate information
        > > you can easily acquire from the variable itself. So why should I
        > > seperate this information that is aquired just as easily?
        > >[/color]
        >
        > Well, as you might argue, I'm not tryng to effect a change in your
        > behaviour, I'm simply trying to point out how it could be made more
        > rational.
        >[/color]
        What would be the difference in his usage and allowing Null in a RDBMS
        column ? Or return NaN instead of raising exception for numeric
        functions ?

        Comment

        • Antoon Pardon

          #49
          Re: &quot;0 in [True,False]&quot; returns True

          Op 2005-12-14, Steve Holden schreef <steve@holdenwe b.com>:[color=blue]
          > Antoon Pardon wrote:[/color]
          [color=blue][color=green][color=darkred]
          >>>It would be somewhat more self-documenting, but why not just use one
          >>>name to indicate the state and another, only meaningful in certain
          >>>states, to indicate the callback?[/color]
          >>
          >>
          >> Why should I do that? Checking the type of a variable is conceptually
          >> no different form testing set membership. So what I did, was just
          >> bringing two disjoint sets togther and working with a variable from
          >> that union. This is all in all a rather simple mathematical idea.
          >> And I don't see why I should put certain information into a seperate
          >> variable. It makes as much sense as working with numbers and using
          >> a seperate variable to store whether a particular number is postive,
          >> even or has some other characteristic. You don't seperate information
          >> you can easily acquire from the variable itself. So why should I
          >> seperate this information that is aquired just as easily?
          >>[/color]
          >
          > Well, as you might argue, I'm not tryng to effect a change in your
          > behaviour, I'm simply trying to point out how it could be made more
          > rational.[/color]

          I guess we will just have to agree to disagree on what is more rational
          in this case. Maybe it is just a case of what idiom one is used to.

          --
          Antoon Pardon

          Comment

          • Grant Edwards

            #50
            Re: &quot;0 in [True,False]&quot; returns True

            On 2005-12-14, bonono@gmail.co m <bonono@gmail.c om> wrote:
            [color=blue][color=green]
            >> Well, as you might argue, I'm not tryng to effect a change in your
            >> behaviour, I'm simply trying to point out how it could be made more
            >> rational.[/color]
            >
            > What would be the difference in his usage and allowing Null in a RDBMS
            > column?[/color]

            Don't know -- homey don't play 'dat.
            [color=blue]
            > Or return NaN instead of raising exception for numeric
            > functions ?[/color]

            Because usually (in my applications anyway) NaN is a perfectly
            valid value and not an "exception" case that needs to be handled.

            --
            Grant Edwards grante Yow! Am I in GRADUATE
            at SCHOOL yet?
            visi.com

            Comment

            • Antoon Pardon

              #51
              Re: &quot;0 in [True,False]&quot; returns True

              Op 2005-12-14, Grant Edwards schreef <grante@visi.co m>:[color=blue]
              > On 2005-12-14, bonono@gmail.co m <bonono@gmail.c om> wrote:
              >[color=green][color=darkred]
              >>> Well, as you might argue, I'm not tryng to effect a change in your
              >>> behaviour, I'm simply trying to point out how it could be made more
              >>> rational.[/color]
              >>
              >> What would be the difference in his usage and allowing Null in a RDBMS
              >> column?[/color]
              >
              > Don't know -- homey don't play 'dat.
              >[color=green]
              >> Or return NaN instead of raising exception for numeric
              >> functions ?[/color]
              >
              > Because usually (in my applications anyway) NaN is a perfectly
              > valid value and not an "exception" case that needs to be handled.[/color]

              I don't see the difference. In my application False and True
              (or Registered and UnRegistered if you prefer) are perfectly valid
              values too. They are not "exception" cases that need to be
              handled.

              --
              Antoon Pardon

              Comment

              • Grant Edwards

                #52
                Re: &quot;0 in [True,False]&quot; returns True

                On 2005-12-14, Antoon Pardon <apardon@forel. vub.ac.be> wrote:
                [color=blue][color=green][color=darkred]
                >>>> Well, as you might argue, I'm not tryng to effect a change in
                >>>> your behaviour, I'm simply trying to point out how it could be
                >>>> made more rational.[/color][/color][/color]
                [...][color=blue][color=green][color=darkred]
                >>> Or return NaN instead of raising exception for numeric
                >>> functions ?[/color]
                >>
                >> Because usually (in my applications anyway) NaN is a perfectly
                >> valid value and not an "exception" case that needs to be
                >> handled.[/color]
                >
                > I don't see the difference. In my application False and True
                > (or Registered and UnRegistered if you prefer) are perfectly
                > valid values too. They are not "exception" cases that need to
                > be handled.[/color]

                Well, in my case, a given name (or return value) is always
                bound to a floating point object. I don't test the type of the
                object and treat it in two different ways depending on what
                type it is. It's just a float.

                --
                Grant Edwards grante Yow! .. Do you like
                at "TENDER VITTLES?"?
                visi.com

                Comment

                • Mike Meyer

                  #53
                  Re: &quot;0 in [True,False]&quot; returns True

                  bonono@gmail.co m writes:[color=blue]
                  > Steve Holden wrote:[color=green][color=darkred]
                  >> >>It would be somewhat more self-documenting, but why not just use one
                  >> >>name to indicate the state and another, only meaningful in certain
                  >> >>states, to indicate the callback?
                  >> > Why should I do that? Checking the type of a variable is conceptually
                  >> > no different form testing set membership. So what I did, was just
                  >> > bringing two disjoint sets togther and working with a variable from
                  >> > that union. This is all in all a rather simple mathematical idea.
                  >> > And I don't see why I should put certain information into a seperate
                  >> > variable. It makes as much sense as working with numbers and using
                  >> > a seperate variable to store whether a particular number is postive,
                  >> > even or has some other characteristic. You don't seperate information
                  >> > you can easily acquire from the variable itself. So why should I
                  >> > seperate this information that is aquired just as easily?[/color]
                  >> Well, as you might argue, I'm not tryng to effect a change in your
                  >> behaviour, I'm simply trying to point out how it could be made more
                  >> rational.[/color]
                  > What would be the difference in his usage and allowing Null in a RDBMS
                  > column ? Or return NaN instead of raising exception for numeric
                  > functions ?[/color]

                  Having a value to indicate "no value" is, of course, perfectly
                  reasonable. However, you then test *for that value*; you don't test
                  the type of the value to see if it's of the right type.

                  Once you get beyond the variable either having a valid value or not,
                  it's really time to consider a different approach. As has been
                  indicated, using two variables is ba well-respected method of doing
                  this. Another alternative (on the spur of the moment - I have no idea
                  how well this will really work) is a value-carrying "invalid value":

                  # untested code:
                  class Invalid:
                  state = 'unknown'

                  ....

                  if self.count is Invalid:
                  if self.count.stat e == 'unregistered':
                  # Register self.
                  elif self.count.stat e == 'registered':
                  # Whatever
                  else:
                  # Deal with self.count outstanding requests

                  Hmm. I'm not sure I like this...

                  <mike
                  --
                  Mike Meyer <mwm@mired.or g> http://www.mired.org/home/mwm/
                  Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

                  Comment

                  • bonono@gmail.com

                    #54
                    Re: &quot;0 in [True,False]&quot; returns True


                    Mike Meyer wrote:[color=blue]
                    > bonono@gmail.co m writes:[color=green]
                    > > Steve Holden wrote:[color=darkred]
                    > >> >>It would be somewhat more self-documenting, but why not just use one
                    > >> >>name to indicate the state and another, only meaningful in certain
                    > >> >>states, to indicate the callback?
                    > >> > Why should I do that? Checking the type of a variable is conceptually
                    > >> > no different form testing set membership. So what I did, was just
                    > >> > bringing two disjoint sets togther and working with a variable from
                    > >> > that union. This is all in all a rather simple mathematical idea.
                    > >> > And I don't see why I should put certain information into a seperate
                    > >> > variable. It makes as much sense as working with numbers and using
                    > >> > a seperate variable to store whether a particular number is postive,
                    > >> > even or has some other characteristic. You don't seperate information
                    > >> > you can easily acquire from the variable itself. So why should I
                    > >> > seperate this information that is aquired just as easily?
                    > >> Well, as you might argue, I'm not tryng to effect a change in your
                    > >> behaviour, I'm simply trying to point out how it could be made more
                    > >> rational.[/color]
                    > > What would be the difference in his usage and allowing Null in a RDBMS
                    > > column ? Or return NaN instead of raising exception for numeric
                    > > functions ?[/color]
                    >
                    > Having a value to indicate "no value" is, of course, perfectly
                    > reasonable. However, you then test *for that value*; you don't test
                    > the type of the value to see if it's of the right type.
                    >
                    > Once you get beyond the variable either having a valid value or not,
                    > it's really time to consider a different approach. As has been
                    > indicated, using two variables is ba well-respected method of doing
                    > this. Another alternative (on the spur of the moment - I have no idea
                    > how well this will really work) is a value-carrying "invalid value":
                    >
                    > # untested code:
                    > class Invalid:
                    > state = 'unknown'
                    >
                    > ...
                    >
                    > if self.count is Invalid:
                    > if self.count.stat e == 'unregistered':
                    > # Register self.
                    > elif self.count.stat e == 'registered':
                    > # Whatever
                    > else:
                    > # Deal with self.count outstanding requests
                    >
                    > Hmm. I'm not sure I like this...
                    >[/color]
                    He doesn't need to test the type, in this case.

                    if self.count is False:
                    elif self.count is True:
                    else:

                    The alternative suggested :

                    if self.state is False:
                    elif self.state is True:
                    else: deal with self.count

                    I don't see much difference. He can also use a better name to represent
                    True/False.

                    Registered=True
                    UnRegistered=Fa lse

                    Comment

                    • Antoon Pardon

                      #55
                      Re: &quot;0 in [True,False]&quot; returns True

                      Op 2005-12-14, Grant Edwards schreef <grante@visi.co m>:[color=blue]
                      > On 2005-12-14, Antoon Pardon <apardon@forel. vub.ac.be> wrote:
                      >[color=green][color=darkred]
                      >>>>> Well, as you might argue, I'm not tryng to effect a change in
                      >>>>> your behaviour, I'm simply trying to point out how it could be
                      >>>>> made more rational.[/color][/color]
                      > [...][color=green][color=darkred]
                      >>>> Or return NaN instead of raising exception for numeric
                      >>>> functions ?
                      >>>
                      >>> Because usually (in my applications anyway) NaN is a perfectly
                      >>> valid value and not an "exception" case that needs to be
                      >>> handled.[/color]
                      >>
                      >> I don't see the difference. In my application False and True
                      >> (or Registered and UnRegistered if you prefer) are perfectly
                      >> valid values too. They are not "exception" cases that need to
                      >> be handled.[/color]
                      >
                      > Well, in my case, a given name (or return value) is always
                      > bound to a floating point object. I don't test the type of the
                      > object and treat it in two different ways depending on what
                      > type it is. It's just a float.[/color]

                      Do you find that difference so important? As far as I understand
                      the gtk identifiers are always positive integers. So I could
                      have coded as follows:

                      UnConnected = (-1, -2)
                      Registered, UnRegistered = UnConnected

                      ...

                      if self.cb_src in UnConnected:

                      Now all values are integers and I no longer treat an object different
                      depending on type but on value. However conceptually nothing changed.
                      My code branches depending on set membership of this attribute.

                      Could you explain why it should make a (big) difference between
                      these two approaches?

                      --
                      Antoon Pardon

                      Comment

                      • bonono@gmail.com

                        #56
                        Re: &quot;0 in [True,False]&quot; returns True


                        Antoon Pardon wrote:[color=blue]
                        > Op 2005-12-14, Grant Edwards schreef <grante@visi.co m>:[color=green]
                        > > On 2005-12-14, Antoon Pardon <apardon@forel. vub.ac.be> wrote:
                        > >[color=darkred]
                        > >>>>> Well, as you might argue, I'm not tryng to effect a change in
                        > >>>>> your behaviour, I'm simply trying to point out how it could be
                        > >>>>> made more rational.[/color]
                        > > [...][color=darkred]
                        > >>>> Or return NaN instead of raising exception for numeric
                        > >>>> functions ?
                        > >>>
                        > >>> Because usually (in my applications anyway) NaN is a perfectly
                        > >>> valid value and not an "exception" case that needs to be
                        > >>> handled.
                        > >>
                        > >> I don't see the difference. In my application False and True
                        > >> (or Registered and UnRegistered if you prefer) are perfectly
                        > >> valid values too. They are not "exception" cases that need to
                        > >> be handled.[/color]
                        > >
                        > > Well, in my case, a given name (or return value) is always
                        > > bound to a floating point object. I don't test the type of the
                        > > object and treat it in two different ways depending on what
                        > > type it is. It's just a float.[/color]
                        >
                        > Do you find that difference so important? As far as I understand
                        > the gtk identifiers are always positive integers. So I could
                        > have coded as follows:
                        >
                        > UnConnected = (-1, -2)
                        > Registered, UnRegistered = UnConnected
                        >
                        > ...
                        >
                        > if self.cb_src in UnConnected:
                        >
                        > Now all values are integers and I no longer treat an object different
                        > depending on type but on value. However conceptually nothing changed.
                        > My code branches depending on set membership of this attribute.
                        >
                        > Could you explain why it should make a (big) difference between
                        > these two approaches?[/color]
                        That is what I would do in C or similar language where a variable can
                        only be one type.

                        Comment

                        • Antoon Pardon

                          #57
                          Re: &quot;0 in [True,False]&quot; returns True

                          Op 2005-12-14, Mike Meyer schreef <mwm@mired.org> :[color=blue]
                          > bonono@gmail.co m writes:[color=green]
                          >> Steve Holden wrote:[color=darkred]
                          >>> >>It would be somewhat more self-documenting, but why not just use one
                          >>> >>name to indicate the state and another, only meaningful in certain
                          >>> >>states, to indicate the callback?
                          >>> > Why should I do that? Checking the type of a variable is conceptually
                          >>> > no different form testing set membership. So what I did, was just
                          >>> > bringing two disjoint sets togther and working with a variable from
                          >>> > that union. This is all in all a rather simple mathematical idea.
                          >>> > And I don't see why I should put certain information into a seperate
                          >>> > variable. It makes as much sense as working with numbers and using
                          >>> > a seperate variable to store whether a particular number is postive,
                          >>> > even or has some other characteristic. You don't seperate information
                          >>> > you can easily acquire from the variable itself. So why should I
                          >>> > seperate this information that is aquired just as easily?
                          >>> Well, as you might argue, I'm not tryng to effect a change in your
                          >>> behaviour, I'm simply trying to point out how it could be made more
                          >>> rational.[/color]
                          >> What would be the difference in his usage and allowing Null in a RDBMS
                          >> column ? Or return NaN instead of raising exception for numeric
                          >> functions ?[/color]
                          >
                          > Having a value to indicate "no value" is, of course, perfectly
                          > reasonable. However, you then test *for that value*; you don't test
                          > the type of the value to see if it's of the right type.
                          >
                          > Once you get beyond the variable either having a valid value or not,
                          > it's really time to consider a different approach.[/color]

                          How do you feel about testing for set membership? I can have a set
                          with values to be treated differently than values not in the set.
                          Do you consider that an acceptable approach?

                          --
                          Antoon Pardon

                          Comment

                          • Grant Edwards

                            #58
                            Re: &quot;0 in [True,False]&quot; returns True

                            On 2005-12-15, Antoon Pardon <apardon@forel. vub.ac.be> wrote:
                            [color=blue][color=green][color=darkred]
                            >>>>> Or return NaN instead of raising exception for numeric
                            >>>>> functions ?
                            >>>>
                            >>>> Because usually (in my applications anyway) NaN is a perfectly
                            >>>> valid value and not an "exception" case that needs to be
                            >>>> handled.
                            >>>
                            >>> I don't see the difference. In my application False and True
                            >>> (or Registered and UnRegistered if you prefer) are perfectly
                            >>> valid values too. They are not "exception" cases that need to
                            >>> be handled.[/color]
                            >>
                            >> Well, in my case, a given name (or return value) is always
                            >> bound to a floating point object. I don't test the type of the
                            >> object and treat it in two different ways depending on what
                            >> type it is. It's just a float.[/color]
                            >
                            > Do you find that difference so important?[/color]

                            Possibly. In my case, a float is always a float. You can
                            always do the same set of operations on it.
                            [color=blue]
                            > As far as I understand
                            > the gtk identifiers are always positive integers. So I could
                            > have coded as follows:
                            >
                            > UnConnected = (-1, -2)
                            > Registered, UnRegistered = UnConnected[/color]

                            In your case, there isn't a single set of operations that work
                            regardles of the value. You have to _check_ the value in order
                            to decide what operations are allowed on that value. I'm not
                            saying the latter is "evil" but I think the distinction is
                            important.
                            [color=blue]
                            > ...
                            >
                            > if self.cb_src in UnConnected:
                            >
                            > Now all values are integers and I no longer treat an object different
                            > depending on type but on value. However conceptually nothing changed.
                            > My code branches depending on set membership of this attribute.
                            >
                            > Could you explain why it should make a (big) difference between
                            > these two approaches?[/color]

                            Your examples are still both very different from the NaN
                            example. A NaN is a floating point operation that supports all
                            the same operations as all other floating point operations. In
                            your example an integer object of -2 does not support the same
                            "operations " that a "real" GTK identifier does. They are two
                            different types.

                            --
                            Grant Edwards grante Yow! Hey, wait a
                            at minute!! I want a
                            visi.com divorce!!... you're not
                            Clint Eastwood!!

                            Comment

                            • Antoon Pardon

                              #59
                              Re: &quot;0 in [True,False]&quot; returns True

                              Op 2005-12-15, Grant Edwards schreef <grante@visi.co m>:[color=blue]
                              > On 2005-12-15, Antoon Pardon <apardon@forel. vub.ac.be> wrote:
                              >[color=green][color=darkred]
                              >>> Well, in my case, a given name (or return value) is always
                              >>> bound to a floating point object. I don't test the type of the
                              >>> object and treat it in two different ways depending on what
                              >>> type it is. It's just a float.[/color]
                              >>
                              >> Do you find that difference so important?[/color]
                              >
                              > Possibly. In my case, a float is always a float. You can
                              > always do the same set of operations on it.
                              >[color=green]
                              >> As far as I understand
                              >> the gtk identifiers are always positive integers. So I could
                              >> have coded as follows:
                              >>
                              >> UnConnected = (-1, -2)
                              >> Registered, UnRegistered = UnConnected[/color]
                              >
                              > In your case, there isn't a single set of operations that work
                              > regardles of the value. You have to _check_ the value in order
                              > to decide what operations are allowed on that value. I'm not
                              > saying the latter is "evil" but I think the distinction is
                              > important.
                              >[color=green]
                              >> ...
                              >>
                              >> if self.cb_src in UnConnected:
                              >>
                              >> Now all values are integers and I no longer treat an object different
                              >> depending on type but on value. However conceptually nothing changed.
                              >> My code branches depending on set membership of this attribute.
                              >>
                              >> Could you explain why it should make a (big) difference between
                              >> these two approaches?[/color]
                              >
                              > Your examples are still both very different from the NaN
                              > example. A NaN is a floating point operation that supports all
                              > the same operations as all other floating point operations. In
                              > your example an integer object of -2 does not support the same
                              > "operations " that a "real" GTK identifier does. They are two
                              > different types.[/color]

                              I think the disctinction you are making is based on which level
                              you look at things. For you floats are something you use, you
                              see NaN as just a floats because the details of implementation
                              have been abstracted out for you.

                              But look at it from the level of someone who has to implement
                              floating point numbers. He can't just take two floats and put
                              them into his general add_float algorithm. If he did that
                              the result of working with a NaN could result in a regular
                              number. So he has to test for special values like NaN is
                              his 'code' too.

                              Of course we tend to forget this because in this case the
                              abstraction is usually done at the hardware level. But
                              I don't think that is such an important disctinction here.

                              --
                              Antoon Pardon

                              Comment

                              • Grant Edwards

                                #60
                                Re: &quot;0 in [True,False]&quot; returns True

                                On 2005-12-16, Antoon Pardon <apardon@forel. vub.ac.be> wrote:
                                [color=blue][color=green]
                                >> Your examples are still both very different from the NaN
                                >> example. A NaN is a floating point operation that supports all
                                >> the same operations as all other floating point operations. In
                                >> your example an integer object of -2 does not support the same
                                >> "operations " that a "real" GTK identifier does. They are two
                                >> different types.[/color]
                                >
                                > I think the disctinction you are making is based on which level
                                > you look at things.[/color]

                                Of course. I was looking at things from a Python point of view
                                since this is c.l.p.
                                [color=blue]
                                > For you floats are something you use, you see NaN as just a
                                > floats because the details of implementation have been
                                > abstracted out for you.[/color]

                                That goes without saying for anything in computer science or
                                electronics: it's all just quantum physics whose details of
                                implimentation have been abstracted out for me.
                                [color=blue]
                                > But look at it from the level of someone who has to implement
                                > floating point numbers. He can't just take two floats and put
                                > them into his general add_float algorithm. If he did that the
                                > result of working with a NaN could result in a regular number.
                                > So he has to test for special values like NaN is his 'code'
                                > too.
                                >
                                > Of course we tend to forget this because in this case the
                                > abstraction is usually done at the hardware level. But I don't
                                > think that is such an important disctinction here.[/color]

                                The distinction is in regards to readability and
                                maintainability of _Python_ code. This is comp.lang.pytho n.

                                --
                                Grant Edwards grante Yow! does your DRESSING
                                at ROOM have enough ASPARAGUS?
                                visi.com

                                Comment

                                Working...