[PYTHON DOC-SIG] String interpolation module

Robin Friedrich friedric@rose.rsoc.rockwell.com
Sun, 20 Oct 1996 12:43:35 -0500


|> From: Ka-Ping Yee <kpyee@aw.sgi.com>
|> Organization: Alias|Wavefront Inc.
|> To: friedric@phoenix.net
|> Cc: doc-sig@python.org
|> Subject: [PYTHON DOC-SIG] String interpolation module
|> 
|> I wrote:
|> > I'm currently thinking of a string interpolation scheme
|> [...]
|> 
|> Robin Friedrich wrote:
|> > 
|> > Dollar signs sends shivers down my spine, but carry on.
|> 
|> Perhaps, but i really don't see much other alternative.
|> Can you think of something better?

No, that's why I said carry on:-)  I'll get over it.

|> 
|> > I think this will be the most controversial of your proposals
|> > but well worth the debate. I'll include it as a definate topic
|> > at the workshop.
|> 
|> Thanks.  Yes, i imagine it is controversial because it makes
|> Python look a little like other languages.  But i don't think
|> that this reaction should overshadow its utility.  Comparing
|> 
|>     "Here is an @{[&functioncall($with, $arguments)]}." (Perl 5)
|> 
|> to
|> 
|>     "Here is a $functioncall(with, arguments)."  (Python + Itpl)
|> 
|> should help to show people that interpolation does NOT necessarily
|> mean riddling the entire language with punctuation.  We're talking
|> one and only one new special character here.

Good point. 
|> 
|> To back up my proposal and give everyone (including myself!) a
|> chance to actually try this out and see how it feels, i've coded
|> up the Itpl module as i described.  Because it is so short
|> (90 lines) i've decided to attach the module to this letter.
|> I hope that subscribers to this list don't mind.

This is one of the many unsung beauties of Python. We can so easily
explore new ideas for improving the language. First we just whip up
something in a python implementation and hash it through until the
design is right and then go ahead and recast it in C if needed for
speed!

I played a little with the Itpl and needed to make the following
change... line 70
while frame.f_globals['__name__'] == name: frame = frame.f_back
to
while frame.f_globals['__name__'] == __name__: frame = frame.f_back

I'm not sure how it ever worked for you. 

Once that's done it worked fine.  I like it alot!

Anyone else have an opinion?    (well I guess this IS the weekend...)

-Robin

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

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