PEP 318 - Function Modifier Syntax

sismex01 at sismex01 at
Wed Jun 11 16:07:01 CEST 2003

> From: Courageous [mailto:jkraska at]
> There are many options:
> Various punctuation-governed:
> 	def myfunc (myvar); synchronized:
> 	def myfunc (myvar), final:

We all know Guido, these are *NEVER* going to fly,
and I at least prefer it like that; this isn't Perl
nor C; if something important, such as function
(and maybe class) modifiers are to pass, they most
surely will be introduced using a keyword or in a
list form:

def myfunc(...args...) [ a, b, c, ...] :

> Modifier tuple first:
> 	def (synchronized) myfunc (myvar):
> 	def (final, synchronized) myfunc (myvar):

Let's be realistic, ok?

> Modifier tuple second:
> 	def myfunc (myvar) (synchronized):
> 	def myfunc (myvar) (final, synchronized):

...has potential, except on Python-Dev it's already
been decided that a list is preferable to a tuple,
in order to keep it readable; two consecutive
tuples have the risk of running into each other,
visually at least.  Change the tuple into a list
and you have:

>>> def myfunc(myvar) [synchronized]: ....

>>> def myfunc(myvar) [final, synchronized]: ....

which reads easier.  Also, your first example has
a bug, your (synchronized) tuple is missing it's
mandatory comma:

>>> def myfunc(myvar) (synchronized,): ....

this mandatory last comma, when there's a single
element in the tuple, kills the tuple form
of modifier sequence, it'll never pass.

> Different keyword:
> 	def myfunction (myvar) using final, synchronized:
> Where "using" is defined to mean "using the semantics
> of".

YES!  This form has much, much potential.  There's the
problem that it's "using <tuple>", but it can be
an alternative, "using <tuple>|<callable>", so that
can be solved.

The "using" pseudo-keyword is the right one, it has
exactly the right subjective meaning, and doesn't
overload any other keyword, pseudo or otherwise.

Thanks CS :-)

Advertencia:La informacion contenida en este mensaje es confidencial y
restringida, por lo tanto esta destinada unicamente para el uso de la
persona arriba indicada, se le notifica que esta prohibida la difusion de
este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
la transmision, favor de comunicarse con el remitente. Gracias.

More information about the Python-list mailing list