Extending Python Syntax with @

Paul McGuire ptmcg at austin.stopthespam_rr.com
Wed Mar 10 22:17:29 EST 2004


"David MacQuigg" <dmq at gain.com> wrote in message
news:s2vu409dio5vc9ndl81dcinteagrkpntf5 at 4ax.com...
> Seems like we need a simple way to extend Python syntax that doesn't
> break existing syntax or clash with any other syntax in Python, is
> easy to type, easy to read, and is clearly distinct from the "base"
> syntax.  Seems like we could put the @ symbol to good use in these
> situations.  Examples:
>
> print @(separator = None) x, y, z
>
> @x,y:x*x+y*y    -- anonymous function
>
> @f(x,y)         -- generator function that can accept new arguments
>                    with each call
>
> @x @y @z        -- short for instance variables in a method definition
>
> Each of these examples is debatable, but my point is that there are
> many enhancement requests like this, and some may be worthy of
> inclusion in the core language.  It would be nice if there was a
> consistent way to add stuff like this.  It certainly beats adding ugly
> statements like 'lambda'.
>
> It might even be possible to allow limited extension of the language
> by users, provided the extensions are introduced by the special
> symbol.  This would allow the flexibility of Ruby or Lisp without the
> cost of forking the language into many dialects.
>
> Maybe we should collect a bunch of little enhancements like the above,
> and put them all into one PEP.  Any suggestions?  Pet peeves?  Stuff
> you would like to see, but not worthy of a PEP by itself?
>
> -- Dave
>
Pet peeve: gratuitous inclusion of magic symbols into an otherwise
easy-to-understand language syntax.

-- Paul





More information about the Python-list mailing list