decorators when?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David C. Ullrich

    decorators when?

    What version added decorators (using the
    @decorator syntax)?

    (Is there a general way I could have found out the answer myself?)

    Is there a somthing such that "from __future__ import something"
    will make decorators work in 2.5.2?


    David C. Ullrich
  • Diez B. Roggisch

    #2
    Re: decorators when?

    David C. Ullrich wrote:
    What version added decorators (using the
    @decorator syntax)?
    >
    (Is there a general way I could have found out the answer myself?)
    >
    Is there a somthing such that "from __future__ import something"
    will make decorators work in 2.5.2?
    They do work. They were introduced in python2.4

    Diez

    Comment

    • David C. Ullrich

      #3
      Re: decorators when?

      On Tue, 27 May 2008 14:50:23 +0200, "Diez B. Roggisch"
      <deets@nospam.w eb.dewrote:
      >David C. Ullrich wrote:
      >
      >What version added decorators (using the
      >@decorator syntax)?
      >>
      >(Is there a general way I could have found out the answer myself?)
      >>
      >Is there a somthing such that "from __future__ import something"
      >will make decorators work in 2.5.2?
      >
      >They do work. They were introduced in python2.4
      That's more or less what I thought, but...

      Oh. Never mind the details, let's just say that having 2.3 and
      2.5 installed on the same machine can lead to confusion
      about exactly which one you're running a script under.
      Duh.

      Sorry. Thanks. I don't suppose that decorators are available
      from __future__ somehow in 2.3?

      >Diez
      David C. Ullrich

      Comment

      • Gabriel Genellina

        #4
        Re: decorators when?

        En Tue, 27 May 2008 11:52:25 -0300, David C. Ullrich
        <dullrich@spryn et.comescribió:
        Oh. Never mind the details, let's just say that having 2.3 and
        2.5 installed on the same machine can lead to confusion
        about exactly which one you're running a script under.
        Duh.
        You might change the prompt; put these lines in your sitecustomize.p y (or
        create it if you don't have one):

        import sys
        sys.ps1 = 'p23'
        sys.ps2 = ' ... '
        Sorry. Thanks. I don't suppose that decorators are available
        from __future__ somehow in 2.3?
        No. But a decorator is only syntax sugar.

        @decorator
        def f():
        ...

        is the same thing as:

        def f():
        ...
        f = decorator(f)

        (just more convenient)

        --
        Gabriel Genellina

        Comment

        • Andrii V. Mishkovskyi

          #5
          Re: decorators when?

          2008/5/27 David C. Ullrich <dullrich@spryn et.com>:
          On Tue, 27 May 2008 14:50:23 +0200, "Diez B. Roggisch"
          <deets@nospam.w eb.dewrote:
          >
          >>David C. Ullrich wrote:
          >>
          >>What version added decorators (using the
          >>@decorator syntax)?
          >>>
          >>(Is there a general way I could have found out the answer myself?)
          >>>
          >>Is there a somthing such that "from __future__ import something"
          >>will make decorators work in 2.5.2?
          >>
          >>They do work. They were introduced in python2.4
          >
          That's more or less what I thought, but...
          >
          Oh. Never mind the details, let's just say that having 2.3 and
          2.5 installed on the same machine can lead to confusion
          about exactly which one you're running a script under.
          Duh.
          >
          Sorry. Thanks. I don't suppose that decorators are available
          from __future__ somehow in 2.3?
          >
          Nope, they don't.
          Anyway, decorators are just a syntactic sugar, why would you need this
          feature in 2.3?

          --
          Wbr, Andrii Mishkovskyi.

          He's got a heart of a little child, and he keeps it in a jar on his desk.

          Comment

          • David C. Ullrich

            #6
            Re: decorators when?

            In article <mailman.1650.1 211901194.12834 .python-list@python.org >,
            "Andrii V. Mishkovskyi" <mishok13@gmail .comwrote:
            2008/5/27 David C. Ullrich <dullrich@spryn et.com>:
            On Tue, 27 May 2008 14:50:23 +0200, "Diez B. Roggisch"
            <deets@nospam.w eb.dewrote:
            >David C. Ullrich wrote:
            >
            >What version added decorators (using the
            >@decorator syntax)?
            >>
            >(Is there a general way I could have found out the answer myself?)
            >>
            >Is there a somthing such that "from __future__ import something"
            >will make decorators work in 2.5.2?
            >
            >They do work. They were introduced in python2.4
            That's more or less what I thought, but...

            Oh. Never mind the details, let's just say that having 2.3 and
            2.5 installed on the same machine can lead to confusion
            about exactly which one you're running a script under.
            Duh.

            Sorry. Thanks. I don't suppose that decorators are available
            from __future__ somehow in 2.3?
            >
            Nope, they don't.
            Anyway, decorators are just a syntactic sugar, why would you need this
            feature in 2.3?
            I don't _need_ it. Read up about decorators the other day at the
            office and couldn't figure out why the same code didn't work at
            home...
            --
            David C. Ullrich

            Comment

            • David C. Ullrich

              #7
              Re: decorators when?

              In article <mailman.1649.1 211900977.12834 .python-list@python.org >,
              "Gabriel Genellina" <gagsl-py2@yahoo.com.a rwrote:
              En Tue, 27 May 2008 11:52:25 -0300, David C. Ullrich
              <dullrich@spryn et.comescribió:
              >
              Oh. Never mind the details, let's just say that having 2.3 and
              2.5 installed on the same machine can lead to confusion
              about exactly which one you're running a script under.
              Duh.
              >
              You might change the prompt; put these lines in your sitecustomize.p y (or
              create it if you don't have one):
              >
              import sys
              sys.ps1 = 'p23'
              sys.ps2 = ' ... '
              Thanks. I guess I should have included details that I thought
              would be of no interest to save people time with replies.

              The problem is that on the Mac in question Terminal thinks
              python is 2.5 (as does Idle) while when I double-click on a
              file in Finder it runs under python 2.3. In particular it
              never happens that I'm running an interactive session under
              2.3.

              (No, I'm not saying that's a good setup - it's a mess. The
              other Mac, at the office, is not such a mess, but I never
              could get things like Idle to work under the Apple Python...)
              Sorry. Thanks. I don't suppose that decorators are available
              from __future__ somehow in 2.3?
              >
              No. But a decorator is only syntax sugar.
              >
              @decorator
              def f():
              ...
              >
              is the same thing as:
              >
              def f():
              ...
              f = decorator(f)
              >
              (just more convenient)
              --
              David C. Ullrich

              Comment

              • Ben Finney

                #8
                When was feature FOO added to Python? (was: decorators when?)

                David C. Ullrich <dullrich@spryn et.comwrites:
                What version added decorators (using the @decorator syntax)?
                >
                (Is there a general way I could have found out the answer myself?)
                For standard library features, the documentation for a module
                <URL:http://www.python.org/doc/lib/usually says "(New in 2.4)" or
                "(Changed in 2.4)" or the like for features that appeared in a
                particular version. I think this is manually done by the
                documentation maintainers, though.

                For features of the language (like decorators), the language reference
                <URL:http://www.python.org/doc/ref/is the place that *describes* the
                features; but I don't see any similar "(New in 2.4)" annotations, so
                e.g. <URL:http://www.python.org/doc/ref/function.htmldo esn't mention
                when the decorator syntax appeared in the language.

                Any documentation maintainers reading: Please consider updating the
                documents to give this useful "(New in 2.x)" or "(Changed in 2.x)"
                annotation for just such a situation.

                You can get closer to the answer by browsing the "What's New in
                Python" <URL:http://www.python.org/doc/2.4/whatsnew/documents by
                version.

                Comment

                • Kam-Hung Soh

                  #9
                  Re: decorators when?

                  David C. Ullrich wrote:
                  What version added decorators (using the
                  @decorator syntax)?
                  >
                  (Is there a general way I could have found out the answer myself?)
                  >
                  Is there a somthing such that "from __future__ import something"
                  will make decorators work in 2.5.2?
                  >
                  >
                  David C. Ullrich
                  See:



                  Dunno of a general way view a list of features versus releases, other
                  than reading the "What's New in Python x" documents. Maybe some
                  enterprising developer can compile this list? Hint, hint.

                  --
                  Kam-Hung Soh <a href="http://kamhungsoh.com/blog">Software Salariman</a>

                  Comment

                  • Terry Reedy

                    #10
                    Re: When was feature FOO added to Python? (was: decorators when?)


                    "Ben Finney" <bignose+hate s-spam@benfinney. id.auwrote in message
                    news:87zlqbs60b .fsf@benfinney. id.au...
                    | David C. Ullrich <dullrich@spryn et.comwrites:
                    |
                    | What version added decorators (using the @decorator syntax)?
                    | >
                    | (Is there a general way I could have found out the answer myself?)
                    |
                    | For standard library features, the documentation for a module
                    | <URL:http://www.python.org/doc/lib/usually says "(New in 2.4)" or
                    | "(Changed in 2.4)" or the like for features that appeared in a
                    | particular version. I think this is manually done by the
                    | documentation maintainers, though.
                    |
                    | For features of the language (like decorators), the language reference
                    | <URL:http://www.python.org/doc/ref/is the place that *describes* the
                    | features; but I don't see any similar "(New in 2.4)" annotations, so
                    | e.g. <URL:http://www.python.org/doc/ref/function.htmldo esn't mention
                    | when the decorator syntax appeared in the language.
                    |
                    | Any documentation maintainers reading: Please consider updating the
                    | documents to give this useful "(New in 2.x)" or "(Changed in 2.x)"
                    | annotation for just such a situation.
                    |
                    | You can get closer to the answer by browsing the "What's New in
                    | Python" <URL:http://www.python.org/doc/2.4/whatsnew/documents by
                    | version.

                    Missing 'New' or 'Changed' annotations might be considered doc bugs.
                    Certainly there should be one for decorators. Anyone who wants such
                    omissions fixed should file a report on bugs.python.org listing the
                    *specific* annotations you think should be added and where. Cite which
                    documents you used as sources so they can be checked. This is something
                    that a new volunteer could do, since it does not need the special skill of
                    older volunteers.

                    Note 1: probably best to check against 2.6 docs, as I am not sure that
                    fixes will go back 2.5.

                    Note 2: the 3.0 docs start with a 'clean slate'. All such annotations are
                    or should be wiped. But changes in 3.1 will be annotated as usual.

                    TJR



                    Comment

                    • Dan Bishop

                      #11
                      Re: decorators when?

                      On May 27, 7:32 pm, Kam-Hung Soh <kamhung....@gm ail.comwrote:
                      David C. Ullrich wrote:
                      What version added decorators (using the
                      @decorator syntax)?
                      >
                      (Is there a general way I could have found out the answer myself?)
                      >
                      Is there a somthing such that "from __future__ import something"
                      will make decorators work in 2.5.2?
                      >
                      David C. Ullrich
                      >
                      See:
                      >

                      >
                      Dunno of a general way view a list of features versus releases, other
                      than reading the "What's New in Python x" documents.  Maybe some
                      enterprising developer can compile this list?  Hint, hint.
                      >>[feature for feature in vars(__future__ ).items() if isinstance(feat ure[1], __future__._Fea ture)]
                      [('nested_scopes ', _Feature((2, 1, 0, 'beta', 1), (2, 2, 0, 'alpha',
                      0), 16)),
                      ('division', _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0),
                      8192)),
                      ('with_statemen t', _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha',
                      0), 32768)),
                      ('absolute_impo rt', _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0,
                      'alpha', 0), 16384)),
                      ('generators', _Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0),
                      0))]

                      Comment

                      Working...