What is not objects in Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriel Genellina

    #31
    Re: What is not objects in Python?

    En Tue, 30 Sep 2008 08:07:18 -0300, Steve Holden <steve@holdenwe b.com>
    escribió:
    Terry Reedy wrote:
    >Steven D'Aprano wrote:
    >>Arghh! No!!! |x| should be abs(x), not len(x). Just ask mathematicians
    >>and physicists.
    >>
    >It should be both, just as + is addition for numbers and concatenation
    >for sequences. Or we could have just one built-in -- size() instead of
    >abs() and len(). For non-sequence collections, size() would be better
    >than len() anyway.
    >>
    And how are these "non-sequence collections" to be distinguished? And
    how does size() differ from len() in that case?
    Consider a tree, or a graph. The number of elements they have is not
    naturally described as their "length", the usual term is "size" instead.
    "Length" is adequate for one-dimensional structures only; even len(dict)
    is a bit controversial.
    Had Python used the more generic size and __size__ from the beginning,
    we'd be all happy now :) But it's too late to change things.

    --
    Gabriel Genellina

    Comment

    • Aaron \Castironpi\ Brady

      #32
      Re: What is not objects in Python?

      On Sep 30, 7:39 am, Steve Holden <st...@holdenwe b.comwrote:
      Steven D'Aprano wrote:
      On Mon, 29 Sep 2008 21:03:07 -0700, namekuseijin wrote:
      >
      >Why isn't len implemented as a str.len and list.len method instead ofa
      >len(list) function?
      Because postfix notation sucks.  The natural way of spelling is
      adjective+noun and verb+predicate.
      >
      "Natural"?
      >
      You mean phrases like "heir apparent" and "worst choice imaginable" are
      unnatural?
      >
      They are certainly far from normal usage, as my dog yellow would be
      certain to agree.
      >
      To say nothing of languages like Spanish, Albanian, Italian,
      Cornish, Vietnamese, Hebrew...
      >
      It's long been a convention in the Western programming world to pretend
      no other language than English and no other codes than ASCII exist.
      >
      The fact that Python is beginning to come to terms with Unicode is a
      tribute to certain developers' persistence.
      >
      regards
       Steve
      --
      Steve Holden        +1 571 484 6266   +1 800 494 3119
      Holden Web LLC              http://www.holdenweb.com/
      How do you have a yellow dog, and what does s/he know about natural
      noun-verb usage?

      Comment

      • Boris Borcic

        #33
        Re: What is not objects in Python?

        42, for instance.

        Proof :
        >>42 is not object
        True

        QED

        Comment

        • William McBrine

          #34
          Re: What is not objects in Python?

          On Wed, 01 Oct 2008 17:56:34 +0200, Boris Borcic wrote:
          42, for instance.
          >
          Proof :
          >
          >>42 is not object
          True
          >
          QED
          >>isinstance(42 , object)
          True

          --
          09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 -- pass it on

          Comment

          • greg

            #35
            Re: What is not objects in Python?

            Gabriel Genellina wrote:
            Had Python used the more generic size and __size__ from the beginning,
            we'd be all happy now :)
            Not necessarily -- len is slightly shorter, and more
            comfortable to type on a qwerty keyboard.

            But in any case, size-likers have an easy solution:

            size = len

            :-)

            (BTW, try doing that with the x.len() notation!)

            --
            Greg


            But it's too late to change things.
            >

            Comment

            • greg

              #36
              Re: What is not objects in Python?

              Aaron "Castironpi " Brady wrote:
              How do you have a yellow dog,
              It's not a yellow dog, it's a dog yellow. Attention pay! :-)

              --
              Ewing Gregory

              Comment

              • Marc 'BlackJack' Rintsch

                #37
                Re: What is not objects in Python?

                On Fri, 03 Oct 2008 19:10:27 +1200, greg wrote:
                But in any case, size-likers have an easy solution:
                >
                size = len
                >
                :-)
                >
                (BTW, try doing that with the x.len() notation!)
                def size(obj):
                return obj.len()

                or

                size = operator.method caller('len')

                in Python 2.6 and up.

                :-)

                Ciao,
                Marc 'BlackJack' Rintsch

                Comment

                • Bruno Desthuilliers

                  #38
                  Re: What is not objects in Python?

                  Boris Borcic a écrit :
                  42, for instance.
                  >
                  Proof :
                  >
                  >>42 is not object
                  True
                  >
                  QED
                  >
                  Lol.

                  Comment

                  • Tim Rowe

                    #39
                    Re: What is not objects in Python?

                    2008/9/30 Lie Ryan <lie.1296@gmail .com>:
                    Actually str.len and len(str) is just like saying "the string's length"
                    and "the length of the string". There is no difference between the two
                    except for personal preference. (I am no linguist-- not even a native
                    speaker of English --but I think there is a subtle difference on
                    emphasis, "the string's length" emphasizes on the length being string's
                    property, while "the length of the string" emphasizes on the length
                    itself, am I correct?)
                    Well, I'm doing a linguistics degree, so I'm not a linguist /yet/, but
                    I think I know this one. There is the difference in emphasis that you
                    mention, but there may be something more significant. In both forms,
                    "length" is what linguists call the "head" of the noun phrase: it's
                    the actual thing being talked about. In "The string's length" the
                    head is only pre-modified ("the string's" comes before the head and
                    there's nothing after the head). "The length of the string" has both
                    pre- and post- modification ("The" before, "of the string" after).
                    Post modification in noun phrases has been measured to be much less
                    frequent in spoken English than in written English, and it gets
                    progressively more common as the writing style gets more formal. That
                    suggests that "the string's length" is an easier phrase to produce and
                    understand, but "the length of the string" sounds more official.

                    --
                    Tim Rowe

                    Comment

                    • Aaron \Castironpi\ Brady

                      #40
                      Re: What is not objects in Python?

                      On Oct 3, 5:10 am, "Tim Rowe" <digi...@gmail. comwrote:
                      2008/9/30 Lie Ryan <lie.1...@gmail .com>:
                      >
                      Actually str.len and len(str) is just like saying "the string's length"
                      and "the length of the string". There is no difference between the two
                      except for personal preference. (I am no linguist-- not even a native
                      speaker of English --but I think there is a subtle difference on
                      emphasis, "the string's length" emphasizes on the length being string's
                      property, while "the length of the string" emphasizes on the length
                      itself, am I correct?)
                      >
                      Well, I'm doing a linguistics degree, so I'm not a linguist /yet/, but
                      I think I know this one. There is the difference in emphasis that you
                      mention, but there may be something more significant. In both forms,
                      "length" is what linguists call the "head" of the noun phrase: it's
                      the actual thing being talked about.  In "The string's length" the
                      head is only pre-modified ("the string's" comes before the head and
                      there's nothing after the head). "The length of the string" has both
                      pre- and post- modification ("The" before, "of the string" after).
                      Post modification in noun phrases has been measured to be much less
                      frequent in spoken English than in written English, and it gets
                      progressively more common as the writing style gets more formal.  That
                      suggests that "the string's length" is an easier phrase to produce and
                      understand, but "the length of the string" sounds more official.
                      >
                      --
                      Tim Rowe
                      .... Unless, there is some corresponding distinction in mechanics
                      between speaking and writing. That is, if something about the process
                      of generating writing makes it, post-modification, easier. I'm going
                      to assume that it's been observed across all modes of writing too, (in
                      addition to across all formality levels), where in all cases it was
                      equally easy to go back and edit, which is impossible in speech. And,
                      in the cases where the entire process of writing was observed, that
                      neither kind of modification occurred more frequently in revisions.

                      Comment

                      • Tim Rowe

                        #41
                        Re: What is not objects in Python?

                        ... Unless, there is some corresponding distinction in mechanics
                        between speaking and writing. That is, if something about the process
                        of generating writing makes it, post-modification, easier. I'm going
                        to assume that it's been observed across all modes of writing too, (in
                        addition to across all formality levels), where in all cases it was
                        equally easy to go back and edit, which is impossible in speech. And,
                        in the cases where the entire process of writing was observed, that
                        neither kind of modification occurred more frequently in revisions.
                        There are such distinctions. In writing, more time is available to
                        produce the text, there is the opportunity to revise the text, the
                        reader has more time to read the text and the reader has the
                        opportunity to re-read the text. Unfortunately, because of the "more
                        time is available to produce the text", observing the writing process
                        would be of limited value.

                        I don't think it's that post-modification becomes easier than
                        pre-modification in writing, I think it's that post-modification
                        becomes more feasible in writing, and is preferred for stylistic
                        reasons.

                        When you say "across all modes of writing" I'm not sure what you mean
                        (linguistically , writing /is/ the mode!) -- I suspect you mean either
                        register (style of writing) or medium (loosely, method of writing).

                        Comment

                        • greg

                          #42
                          Re: What is not objects in Python?

                          Marc 'BlackJack' Rintsch wrote:
                          On Fri, 03 Oct 2008 19:10:27 +1200, greg wrote:
                          >>(BTW, try doing that with the x.len() notation!)
                          def size(obj):
                          return obj.len()
                          >
                          or
                          >
                          size = operator.method caller('len')
                          No, what I meant was that if the normal way of getting
                          the len of something were to write x.len() instead of
                          len(x), you wouldn't be able to globally substitute
                          that syntax with x.size().

                          --
                          Greg

                          Comment

                          Working...