PEP 318 - Function Modifier Syntax

Bengt Richter bokr at oz.net
Tue Jun 10 21:21:12 CEST 2003


On Tue, 10 Jun 2003 13:56:06 -0400, Lulu of the Lotus-Eaters <mertz at gnosis.cx> wrote:

>|>        def foo(self) {'pre': synchronized(lock), 'classmethod': True}:
>|>            """ Skip Montanaro syntax """
>|>            perform method operation
>|         MOD_SYN_METH = {'pre': synchronized(lock), 'classmethod': True}
>|         def foo(self) MOD_SYN_METH:
>
>I would call the dictionary option dead-in-the-water.  Dictionaries do
>not have orders, and therefore do not let you specify the order in which
>modifiers are applied.
>
I recognized the ordering problem and wrote:
"""
... But there has to be some control definition for how/when
to use the things in the dict (noting that there is at least def-time vs call time).
I would designate an optional overriding  mod function right in the dict itself
using a special key, e.g., 'mod_fun'

         MOD_SYN_METH = {'mod_fun': mod_syn, 'pre': synchronized(lock), 'classmethod': True}
         def foo(self) MOD_SYN_METH:
             """ Skip Montanaro syntax with Bengt's mod """
             perform method operation

The implied processing might be

         foo = MOD_SYN_METH.get('mod_fun', std_mod_fun)(foo, MOD_SYN_METH, locs=locals(), globs=globals())
"""

Probably I threw in too many ideas at once ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list