[Python-Dev] PEP 215 redux: toward a simplified consensus?

Guido van Rossum guido@python.org
Mon, 25 Feb 2002 13:33:32 -0500


[Barry]
> > Guido's rules for $-substitutions are really simple:
> > 
> > 1. $$ substitutes to just a single $
> > 
> > 2. $identifier followed by non-identifier characters gets interpolated
> >    with the value of the 'identifier' key in the substitution
> >    dictionary.
> > 
> > 3. For handling cases where the identifier is followed by identifier
> >    characters that aren't part of the key, ${identfier} is equivalent
> >    to $identifier.
> > 
> > And that's it.  For the sake of discussion, forget about where the
> > dictionary for string interpolation comes from.

[MAL]
> Wouldn't it be a lot simpler and more inline with what we
> already have, if we'd use '%' as escape characters ?
> 
> 1. %% becomes %
> 
> 2. %ident maps to %(ident)s as we have it now
> 
> 3. %{ident} maps to %(ident)s
> 
> 4. %(ident)s continues to have the same semantics as
>    before

That's not simpler, it's more complicated.  Any tool dealing with
these will have to understand all the rules.

The point of switching to $ is twofold: (1) it avoids confusion with
the old %-based syntax (which can continue to exist for different
purposes), (2) it is familiar to people who have seen substitution in
other languages.  $ is nearly universal (Perl, Tcl, Ruby, shell, etc.)

--Guido van Rossum (home page: http://www.python.org/~guido/)