backquote

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Olaf Meding

    backquote

    Is `object` (using backquotes) the same as saying str(object)? Trying
    to understand how backquotes work. Thanks for your help.

    Olaf
  • Sean Ross

    #2
    Re: backquote

    "Olaf Meding" <OlafMeding@com puserve.com> wrote in message
    news:9e5ea2c4.0 403110753.5c4d4 37a@posting.goo gle.com...[color=blue]
    > Is `object` (using backquotes) the same as saying str(object)? Trying
    > to understand how backquotes work. Thanks for your help.
    >
    > Olaf[/color]
    [color=blue][color=green][color=darkred]
    >>> class C:[/color][/color][/color]
    .... def __repr__(self):
    .... return "repr"
    .... def __str__(self):
    .... return "str"
    ....[color=blue][color=green][color=darkred]
    >>> c = C()
    >>> str(c)[/color][/color][/color]
    'str'[color=blue][color=green][color=darkred]
    >>> repr(c)[/color][/color][/color]
    'repr'[color=blue][color=green][color=darkred]
    >>> `c`[/color][/color][/color]
    'repr'[color=blue][color=green][color=darkred]
    >>>[/color][/color][/color]



    Comment

    • Skip Montanaro

      #3
      Re: backquote


      Olaf> Is `object` (using backquotes) the same as saying str(object)?
      Olaf> Trying to understand how backquotes work. Thanks for your help.

      `object` is equivalent to repr(object).

      Skip

      Comment

      • Paul McGuire

        #4
        Re: backquote

        "Skip Montanaro" <skip@pobox.com > wrote in message
        news:mailman.27 7.1079020800.19 534.python-list@python.org ...[color=blue]
        >
        > Olaf> Is `object` (using backquotes) the same as saying str(object)?
        > Olaf> Trying to understand how backquotes work. Thanks for your help.
        >
        > `object` is equivalent to repr(object).
        >
        > Skip
        >[/color]
        Is this syntax one of those vestigial short-cuts that is on somebody's hit
        list for future deprecation? To my eyes, `object` is more arcane than
        repr(object) - why else would we be having this thread in the first place?

        -- Paul


        Comment

        • John Roth

          #5
          Re: backquote

          "Paul McGuire" <bogus@bogus.ne t> wrote in message
          news:OW14c.904$ vI3.875@fe2.tex as.rr.com...[color=blue]
          > "Skip Montanaro" <skip@pobox.com > wrote in message
          > news:mailman.27 7.1079020800.19 534.python-list@python.org ...[color=green]
          > >
          > > Olaf> Is `object` (using backquotes) the same as saying str(object)?
          > > Olaf> Trying to understand how backquotes work. Thanks for your[/color][/color]
          help.[color=blue][color=green]
          > >
          > > `object` is equivalent to repr(object).
          > >
          > > Skip
          > >[/color]
          > Is this syntax one of those vestigial short-cuts that is on somebody's hit
          > list for future deprecation? To my eyes, `object` is more arcane than
          > repr(object) - why else would we be having this thread in the first place?[/color]

          I believe so. It's scheduled for removal in Python 3.0 or at the heat
          death of the universe, whichever comes first.

          John Roth[color=blue]
          >
          > -- Paul
          >
          >[/color]


          Comment

          • Skip Montanaro

            #6
            Re: backquote

            [color=blue][color=green]
            >> `object` is equivalent to repr(object).[/color][/color]

            Paul> Is this syntax one of those vestigial short-cuts that is on
            Paul> somebody's hit list for future deprecation?

            I suspect so, but not before Python 3.

            Skip

            Comment

            • David MacQuigg

              #7
              Re: backquote

              On Thu, 11 Mar 2004 18:08:46 GMT, "Paul McGuire" <bogus@bogus.ne t>
              wrote:
              [color=blue]
              >"Skip Montanaro" <skip@pobox.com > wrote in message
              >news:mailman.2 77.1079020800.1 9534.python-list@python.org ...[color=green]
              >>
              >> Olaf> Is `object` (using backquotes) the same as saying str(object)?
              >> Olaf> Trying to understand how backquotes work. Thanks for your help.
              >>
              >> `object` is equivalent to repr(object).
              >>
              >> Skip
              >>[/color]
              >Is this syntax one of those vestigial short-cuts that is on somebody's hit
              >list for future deprecation? To my eyes, `object` is more arcane than
              >repr(object) - why else would we be having this thread in the first place?[/color]

              see GvR's comments at:
              The official home of the Python Programming Language


              He is recommending we drop `x` in favor of repr(x)

              -- Dave

              Comment

              • Gerrit

                #8
                Re: backquote

                Paul McGuire wrote:[color=blue]
                > "Skip Montanaro" <skip@pobox.com > wrote in message
                > news:mailman.27 7.1079020800.19 534.python-list@python.org ...[color=green]
                > >
                > > Olaf> Is `object` (using backquotes) the same as saying str(object)?
                > > Olaf> Trying to understand how backquotes work. Thanks for your help.
                > >
                > > `object` is equivalent to repr(object).
                > >
                > > Skip
                > >[/color]
                > Is this syntax one of those vestigial short-cuts that is on somebody's hit
                > list for future deprecation? To my eyes, `object` is more arcane than
                > repr(object) - why else would we be having this thread in the first place?[/color]

                Indeed. Recently (current CVS) a patch was applied removing almost all
                occurences of backquotes in the standard library, and they will be
                removed in Python 3.0. I believe Guido regrets them.

                Gerrit.

                --
                Weather in Twenthe, Netherlands 11/03 20:25 UTC:
                2.0°C wind 2.7 m/s E (57 m above NAP)
                --
                Asperger's Syndrome - a personal approach:


                Comment

                • Dan Bishop

                  #9
                  Re: backquote

                  OlafMeding@comp userve.com (Olaf Meding) wrote in message news:<9e5ea2c4. 0403110753.5c4d 437a@posting.go ogle.com>...[color=blue]
                  > Is `object` (using backquotes) the same as saying str(object)? Trying
                  > to understand how backquotes work. Thanks for your help.[/color]

                  It's the same as using "repr(objec t)".

                  Comment

                  Working...