473,287 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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
Jun 27 '08 #1
10 1019
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
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
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
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
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
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
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
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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it...
17
by: daishi | last post by:
For what it's worth: As far as I know, the proposed @decorator syntax will be the first time that two logical lines of python with the same indentation will not be independent of one another....
8
by: Michele Simionato | last post by:
Decorators can generate endless debate about syntax, but can also be put to better use ;) Actually I was waiting for decorators to play a few tricks that were syntactically too ugly to be even...
4
by: RebelGeekz | last post by:
Just my humble opinion: def bar(low,high): meta: accepts(int,int) returns(float) #more code Use a metadata section, no need to introduce new messy symbols, or mangling our beloved visual...
2
by: Guido van Rossum | last post by:
Robert and Python-dev, I've read the J2 proposal up and down several times, pondered all the issues, and slept on it for a night, and I still don't like it enough to accept it. The only reason...
0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
9
by: Bengt Richter | last post by:
;-) We have @deco def foo(): pass as sugar (unless there's an uncaught exception in the decorator) for def foo(): pass foo = deco(foo) The binding of a class name is similar, and class...
4
by: John Henry | last post by:
I must be very thick. I keep reading about what decorators are and I still don't have a good feel about it. See, for example: http://alex.dojotoolkit.org/?p=564 and: ...
2
by: Andrew West | last post by:
Probably a bit of weird question. I realise decorators shouldn't be executed until the function they are defined with are called, but is there anyway for me to find all the decorates declared in a...
0
by: Gabriel Genellina | last post by:
En Tue, 29 Jul 2008 08:45:02 -0300, Themis Bourdenas <bourdenas@gmail.com> escribi�: In a very strict sense, I'd say that all those references to "method decorators" are wrong - because...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.