By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,173 Members | 796 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,173 IT Pros & Developers. It's quick & easy.

decorators when?

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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
Jun 27 '08 #2

P: n/a
On Tue, 27 May 2008 14:50:23 +0200, "Diez B. Roggisch"
<de***@nospam.web.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
Jun 27 '08 #3

P: n/a
En Tue, 27 May 2008 11:52:25 -0300, David C. Ullrich
<du******@sprynet.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.py (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

Jun 27 '08 #4

P: n/a
2008/5/27 David C. Ullrich <du******@sprynet.com>:
On Tue, 27 May 2008 14:50:23 +0200, "Diez B. Roggisch"
<de***@nospam.web.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?
>
>>Diez

David C. Ullrich
--
http://mail.python.org/mailman/listinfo/python-list


--
Wbr, Andrii Mishkovskyi.

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

P: n/a
In article <ma***************************************@python. org>,
"Andrii V. Mishkovskyi" <mi******@gmail.comwrote:
2008/5/27 David C. Ullrich <du******@sprynet.com>:
On Tue, 27 May 2008 14:50:23 +0200, "Diez B. Roggisch"
<de***@nospam.web.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...
>Diez
David C. Ullrich
--
http://mail.python.org/mailman/listinfo/python-list
--
David C. Ullrich
Jun 27 '08 #6

P: n/a
In article <ma***************************************@python. org>,
"Gabriel Genellina" <ga*******@yahoo.com.arwrote:
En Tue, 27 May 2008 11:52:25 -0300, David C. Ullrich
<du******@sprynet.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.py (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
Jun 27 '08 #7

P: n/a
David C. Ullrich <du******@sprynet.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.htmldoesn'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.
Jun 27 '08 #8

P: n/a
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:

http://www.python.org/doc/2.4/whatsnew/whatsnew24.html

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>

Jun 27 '08 #9

P: n/a

"Ben Finney" <bi****************@benfinney.id.auwrote in message
news:87************@benfinney.id.au...
| David C. Ullrich <du******@sprynet.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.htmldoesn'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

Jun 27 '08 #10

P: n/a
On May 27, 7:32*pm, Kam-Hung Soh <kamhung....@gmail.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:

http://www.python.org/doc/2.4/whatsnew/whatsnew24.html

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(feature[1], __future__._Feature)]
[('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_statement', _Feature((2, 5, 0, 'alpha', 1), (2, 6, 0, 'alpha',
0), 32768)),
('absolute_import', _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))]

Jun 27 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.