expression form of one-to-many dict?

Mike Meyer mwm at
Tue Dec 21 00:56:06 CET 2004

bokr at (Bengt Richter) writes:

> On Sun, 19 Dec 2004 21:29:27 +0100, "Fredrik Lundh" <fredrik at> wrote:
> (or maybe a restricted unquote_arg function for better safety).
> E.g., double back-tick is a syntax error now, so you could write
>     def ternary(c, ``t, ``f):
>         if c: return eval(t)
>         else: return eval(f)

Actually, I think it would be more pythonic if the indication of
non-evaluation happened at the function invocation instead of the
function definition. Having it at the function definition makes it
implicit at the function invocation point.  Having functions that
expect objects of certain types (closures in this case, right?) is
pretty much standard operating procedure.

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the Python-list mailing list