[PYTHON DOC-SIG] String interpolation module

Marc-Andre Lemburg ikds@fashion-forum.de
Wed, 23 Oct 1996 14:18:32 +0200


Hi !

I just tried your Itpl class. Looks like a nice approach in general,
although the implementation does have it's quirks (jumping through
frames and stuff like that).

Here two suggestions I'd like to make:

1. Why not use a syntax that would also include on-the-fly
   formatting (e.g. something resembling '%2.2f'%y) ? I would
   suggest using:

   "global optimum found at x = %2.2f{calc_opt(params)}"

   which could be done in your syntax with:

   "global optimum found at x = ${'%2.2f'%calc_opt(params)}"

    That way we wouldn't leave the tracks of using C style
    %2i too much, while still having all the goodies of doing
    inline evaluation.

    The syntax would then be:
       
      %{some + expression}  ... having no formatting string

    and

      %2.2f{some + calculations} ... using %2.2f as formatting string

    (i.e. you can look for %{...} while parsing the string)

2. Wouldn't it be easier to just convert the above strings to
   normal Python syntax and then letting Python evaluate the whole
   string%tupel, rather than doing the whole parsing by yourself ?

cheers, Marc
-----------------------------------------------------------------------
lemburg@informatik.uni-koeln.de                      Marc-Andre Lemburg

=================
DOC-SIG  - SIG for the Python Documentation Project

send messages to: doc-sig@python.org
administrivia to: doc-sig-request@python.org
=================