473,387 Members | 1,440 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,387 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 1023
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.