473,388 Members | 1,400 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,388 software developers and data experts.

Poll - Vote here for "list-after-def" (was Decorator syntax)

Paul McGuire wrote:
Please reconsider the "def f() [classmethod]:" construct. Instead of
invoking a special punctuation character, it uses context and placement,
with familiar old []'s, to infuse the declaration of a function with special
characteristics. If this causes def lines to run longer than one line,
perhaps the same rule that allows an unmatched "(" to carry over multiple
lines without requiring "\" continuation markers could be used for unmatched
"["s, as in:

def f() [ staticmethod,
synchronized,
alphabetized,
supersized,
returns('d') ]:


Well said!

Reading the posts here and in the python-dev I've counted
the following votes for it (I'm sure that there were a lot
more but it is awfully hard to keep up with the posts
on the topic).

Voting for the "list-after-def" syntax as shown above:

Peter Hansen <pe***@engcorp.com>
AdSR <ar**********@yahoo.com>
Paul McGuire <pt***@austin.rr._bogus_.com>m
Phillip J. Eby pje at telecommunity.com
C. Barnes <co************@yahoo.com>
Aahz aahz at pythoncraft.com
Skip Montanaro skip at pobox.com
Bill Janssen janssen at parc.com
Istvan Albert ia*****@mailblocks.com

I have the feeling that this always was and still is
the favorite.

Ladies and Gents, start your engines and rally around
this syntax (if you prefer it of course) so that there
is evidence that it should be taken as a serious candidate.

Istvan.

Jul 18 '05 #1
17 1897
Istvan Albert wrote:
Paul McGuire wrote:
Please reconsider the "def f() [classmethod]:" construct.


I concur.

The @ construct is atrocious and *very* unpythonic. I would choose no
changes at all over implementing the @ construct. list-after-def is
much, much, *much* better.
Greg Krohn
(I feel more strongly about this than I did (do) about PEP 308.)
Jul 18 '05 #2
The solution, if you don't like the syntax, is not voting. It's to propose an
argument that Guido will accept, in favour of your preferred option.
Jul 18 '05 #3
On Thu, 05 Aug 2004 22:39:19 -0400, Istvan Albert
<ia*****@mailblocks.com> wrote:

Ladies and Gents, start your engines and rally around
this syntax (if you prefer it of course) so that there
is evidence that it should be taken as a serious candidate.


+1

I greatly prefer it over the @ syntax.
Jul 18 '05 #4

The "list-after-def" is my preference as well, more than +1. It
matches existing Python syntax by using a list (or tuple?) notation,
the list of keywords can span one or multiple lines and it can easily
be extended with additional keywords as the need arises in the future.

Apart from being non-Pythonic, my objection against the @ proposal is
that it can easily be confused with comments like the (Java) doc-like
notations.

I am not qualfied to judge backward possible compatibility issues.

/Jean Brouwers

In article <6L********************@giganews.com>, Istvan Albert
<ia*****@mailblocks.com> wrote:
Paul McGuire wrote:
> Please reconsider the "def f() [classmethod]:" construct. Instead of
> invoking a special punctuation character, it uses context and placement,
> with familiar old []'s, to infuse the declaration of a function with
> special
> characteristics. If this causes def lines to run longer than one line,
> perhaps the same rule that allows an unmatched "(" to carry over multiple
> lines without requiring "\" continuation markers could be used for
> unmatched
> "["s, as in:
>
> def f() [ staticmethod,
> synchronized,
> alphabetized,
> supersized,
> returns('d') ]:


Well said!

Reading the posts here and in the python-dev I've counted
the following votes for it (I'm sure that there were a lot
more but it is awfully hard to keep up with the posts
on the topic).

Voting for the "list-after-def" syntax as shown above:

Peter Hansen <pe***@engcorp.com>
AdSR <ar**********@yahoo.com>
Paul McGuire <pt***@austin.rr._bogus_.com>m
Phillip J. Eby pje at telecommunity.com
C. Barnes <co************@yahoo.com>
Aahz aahz at pythoncraft.com
Skip Montanaro skip at pobox.com
Bill Janssen janssen at parc.com
Istvan Albert ia*****@mailblocks.com

I have the feeling that this always was and still is
the favorite.

Ladies and Gents, start your engines and rally around
this syntax (if you prefer it of course) so that there
is evidence that it should be taken as a serious candidate.

Istvan.

Jul 18 '05 #5
Istvan Albert <ia*****@mailblocks.com> wrote in message news:<6L********************@giganews.com>...
Paul McGuire wrote:
> Please reconsider the "def f() [classmethod]:" construct. Instead of
> invoking a special punctuation character, it uses context and placement,
> with familiar old []'s, to infuse the declaration of a function with special
> characteristics. If this causes def lines to run longer than one line,
> perhaps the same rule that allows an unmatched "(" to carry over multiple
> lines without requiring "\" continuation markers could be used for unmatched
> "["s, as in:
>
> def f() [ staticmethod,
> synchronized,
> alphabetized,
> supersized,
> returns('d') ]:


Well said!
<snip>
I have the feeling that this always was and still is
the favorite.


By the way, does anybody remember the first proposed syntax?

def f() as staticmethod, synchronized, alphabetized, \
supersized, returns('d'):
pass

Nowadays I'm more in favor of the list syntax, since in the future it
could be dynamized by allowing list comprehension. Not that you can't
achieve the same goal with static decorator list, using a decorator
that iterates over that dynamic list of decorators that you want.

Waking-up-the-dead-ly yours,

AdSR
Jul 18 '05 #6
Vote...

And what is the position from Kerry and/or Bush ?

Jul 18 '05 #7
Istvan Albert wrote:
Paul McGuire wrote:
> Please reconsider the "def f() [classmethod]:" construct.
>
> def f() [ staticmethod,
> synchronized,
> alphabetized,
> supersized,
> returns('d') ]:

Nobody has bothered to post an example with a long argument list,
thus ignoring the possibly valid claim in the PEP that this would
make the decorator list hard to see. Here goes:

def someMethod(self, posArgOne, anotherArg,
fieldX=56,
x=5, y=7, z=9,
**kwargs)
[
staticmethod,
synchronized,
alphabetized,
supersized,
returns('d')
]:

Okay, pretty much an abomination, but I'm not sure it's any worse than
the alternative with @:

@staticmethod
@synchronized
@alphabetized
@supersized
@returns('d')
def someMethod(self, posArgOne, anotherArg,
fieldX=56,
x=5, y=7, z=9,
**kwargs):

It *is*, however, fairly clear that the list of decorators becomes
harder to see. Without checking, it's definitely possible that the
decorator list in the first case is actually part of the argument list.

I don't care. I still prefer it to @, if nothing else because
it's much more intuitive to a Python programmer what order they
will be applied in.
Voting for the "list-after-def" syntax as shown above:


Apparently the term "voting" is deprecated when related to PEPs
and language design. ;-) Instead, we should now be using the term
"expressing their opinion in favour of"...

At least, I hope we are still allowed to express opinions in favour
of things...

-Peter
Jul 18 '05 #8
On Thu, 5 Aug 2004, Istvan Albert wrote:
Ladies and Gents, start your engines and rally around
this syntax (if you prefer it of course) so that there
is evidence that it should be taken as a serious candidate.


My vote goes to this. If we have to have decorators, this is how they
should look.

Jul 18 '05 #9
Istvan Albert wrote:

....
Ladies and Gents, start your engines and rally around
this syntax (if you prefer it of course) so that there
is evidence that it should be taken as a serious candidate.


You have my full support.
Although I'm not sure if we still have an option
to choose at all.

+1

--
Christian Tismer :^) <mailto:ti****@stackless.com>
Mission Impossible 5oftware : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a : *Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34 home +49 30 802 86 56 mobile +49 173 24 18 776
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/

Jul 18 '05 #10
On Fri, 6 Aug 2004, Anthony Baxter wrote:
The solution, if you don't like the syntax, is not voting. It's to
propose an argument that Guido will accept, in favour of your preferred
option.


We can't propose a dozen different syntaxes. We're voting for our
benefit, not his. The argument presented will be built around the syntax
voted for here.

Jul 18 '05 #11
On Fri, 6 Aug 2004, Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle. wrote:
And what is the position from Kerry
"Decorators should come in a list after the function definition. Having
decorarotrs in a list before the function definition is surely the best
way to go. When you have @decorators, everything works out well. Adding
keywords is what this country is all about!"
and/or Bush ?


"Is our decorators working?"

Jul 18 '05 #12
On Fri, 06 Aug 2004 08:24:47 -0400, Peter Hansen <pe***@engcorp.com> wrote:
It *is*, however, fairly clear that the list of decorators becomes
harder to see. Without checking, it's definitely possible that the
decorator list in the first case is actually part of the argument list.
This is one of the reasons Guido rejected it, see
http://mail.python.org/pipermail/pyt...st/047112.html
Apparently the term "voting" is deprecated when related to PEPs
and language design. ;-) Instead, we should now be using the term
"expressing their opinion in favour of"...
Well, it's not so much deprecated as pointless <wink>
At least, I hope we are still allowed to express opinions in favour
of things...


In case it wasn't clear from my earlier posts - my comments about "voting"
being a waste of time were meant in the sense of "collecting a bunch of
votes won't achieve anything". Collecting a rationale that is sufficient to
change Guido's mind, however, is encouraged! But simply saying "here's
a list of people who prefer this syntax" won't achieve much at all. Far
better use of time is to work out a way to convince Guido to change his
mind (which, it should be clear from the post above, will require a strong
argument, with good reasons for it).
Jul 18 '05 #13
> Please reconsider the "def f() [classmethod]:" construct.

+1 from me.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Jul 18 '05 #14
Anthony Baxter wrote:
The solution, if you don't like the syntax, is not voting. It's to propose an
argument that Guido will accept, in favour of your preferred option.


Yes, I suppose so. +1 in favor of Anthony's proposal to come up with a
persuasive argument instead of 'voting'. ;)

The reason I don't like the proposed @ construct is that the decorators
don't seem to be actually part of the function def. They seem to be
separate statements before the def. With the list-after-def construct
the decorators appear after 'def' and before ':'; clearly part of the
function def.

I will concede that the @ example someone posted with a long argument
list is slightly more readable than the corresponding list-after-def.
BUT, I think with a shorter arg list list-after-def is more
readable/intuitive. I believe that shorter args lists are more common
than long ones. I think the decorator syntax should favor the more
common usage.
Greg Krohn
Jul 18 '05 #15
On Fri, 06 Aug 2004 08:24:47 -0400, Peter Hansen <pe***@engcorp.com> wrote:
Istvan Albert wrote:
Paul McGuire wrote:
> Please reconsider the "def f() [classmethod]:" construct.
>
> def f() [ staticmethod,
> synchronized,
> alphabetized,
> supersized,
> returns('d') ]:

Nobody has bothered to post an example with a long argument list,
thus ignoring the possibly valid claim in the PEP that this would
make the decorator list hard to see. Here goes:

def someMethod(self, posArgOne, anotherArg,
fieldX=56,
x=5, y=7, z=9,
**kwargs)
[
staticmethod,
synchronized,
alphabetized,
supersized,
returns('d')
]:

Okay, pretty much an abomination, but I'm not sure it's any worse than
the alternative with @:

@staticmethod
@synchronized
@alphabetized
@supersized
@returns('d')
def someMethod(self, posArgOne, anotherArg,
fieldX=56,
x=5, y=7, z=9,
**kwargs):

It *is*, however, fairly clear that the list of decorators becomes
harder to see. Without checking, it's definitely possible that the
decorator list in the first case is actually part of the argument list.

It seems to me that all the proposed syntaxes have in common the purpose
of creating an ordered set of functions to be applied in order to the
result of a def. Why not accept this and use a builtin object to hold
the temporary function sequence? Thus you could have a method (or __call__)
add one or more functions to the temporary set contained in the builtin object.

Then the list of functions can be the argument list to a method of the builtin
object instead of list syntax magically interpreted in list-after-def context,
magically saving the sequence in a magic internal place (as opposed to programmer-known
and overrideable). If you had a builtin object and a builtin userfriendly
alias for a method that adds one or more decorators to its list (that gets used
up at the end of the next def), then you could write (picking decorate as user-friendly ;-)

decorate(staticmethod, synchronized, alphabetized, supersized)
decorate(returns('d'))
def someMethod(self, posArgOne, anotherArg,
fieldX=56,
x=5, y=7, z=9,
**kwargs
): #I like it better here for multiline arg lists ;-)
# ...

def implementation would have to be modified to look for the builtin object
and get the decorator functions from there. You could choose to look for
a shadowing name binding starting with locals(), or you could only allow
a shadowing starting at globals() I suppose, for speed.

BTW, is @decorator thread-safe? I guess it would be something to be careful
about in a really dynamic object-oriented implementation.
I don't care. I still prefer it to @, if nothing else because
it's much more intuitive to a Python programmer what order they
will be applied in.

'@x' as a spelling of
__programmer_inaccessible_hidden_system_temp_list. append(x) # or is it 'x' ?
seems not the best use of '@' to me.

Regards,
Bengt Richter
Jul 18 '05 #17
Istvan Albert wrote:
Voting for the "list-after-def" syntax as shown above:

Peter Hansen <pe***@engcorp.com>
AdSR <ar**********@yahoo.com>
Paul McGuire <pt***@austin.rr._bogus_.com>m
Phillip J. Eby pje at telecommunity.com
C. Barnes <co************@yahoo.com>
Aahz aahz at pythoncraft.com
Skip Montanaro skip at pobox.com
Bill Janssen janssen at parc.com
Istvan Albert ia*****@mailblocks.com


+1

Reinhold

--
Wenn eine Linuxdistribution so wenig brauchbare Software wie Windows
mitbrächte, wäre das bedauerlich. Was bei Windows der Umfang eines
"kompletten Betriebssystems" ist, nennt man bei Linux eine Rescuedisk.
-- David Kastrup in de.comp.os.unix.linux.misc
Jul 18 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: spencer | last post by:
Hi, I'm using NumPy to build an array of a list of names that will be of multiple dimensions.I did do a google on this subject, but couldn't find what I was looking for. The problem I'm having...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
2
by: thomasfj | last post by:
Hi, Accroding to MS documentation the use of union and list elements in XSD simpleType (valid according to W3C standards) is valid used as an dataset schema...but it's not!! When loading the...
9
by: Marco Castro | last post by:
I tried to google for information of what the output of the "LIST" command means but couldn't find any articles that tell me exactly what every character means. I can figure out most of it, its...
2
by: mfilion | last post by:
Hey all, I have a problem with my the Form I built, hopefully someone here can help me out! I'm still a beginner, so bear with me! Here goes... The form contains many boxes, each of which...
5
by: krwill | last post by:
I'm trying to automate a combo box to add a record to the source table if it's "Not In List". I've tried many different examples and none have worked. Combo Box Name = Combo24 Source Table...
4
by: zacks | last post by:
Most applications whose purpose is to work with various types of files implement a "Most Recent Files" list, where the last, say, four files accessed by the application can quickly be re-opened by...
11
by: kimiraikkonen | last post by:
Hello, I'm very new to C# and just installed VC# 2005 express edition and i have VB 2005 express installed previously. But i saw a thing which may be called as a "Visual C# 2005 express" bug? ...
0
by: howkoss | last post by:
Hi, I've been very frustrated for 2 days trying to make this work. I started with a built-in template "Projects" that came with Access 2007. On the "Employee List" I can click on any cell and bring...
6
by: mh | last post by:
I googled and wiki'ed, but couldn't find a concise clear answer as to how python "list comprehensions" got their name. Who picked the name? What was the direct inspiration, another language? ...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.