Re: Multi-line string extension

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Tue, 19 Apr 1994 15:58:51 -0400

On Apr 19, 13:02, Donald Beaudry wrote:
>
> I agree with Tim on this point. Symbolic access is much better than
> those silly little integers. [ ... ]
>
> print message % {'month':10, 'day':13, 'year':89}
>
> where message is somthing that was read out of a local or language
> specific database and contains somthing that looks like:
>
> 'the date is %(month)/%(day)/%(year)'
> or
> 'the date is %(day)/%(month)/%(year)'
>

In general: I like it!

> >>>>> On Tue, 19 Apr 94 04:27:11 -0400, Tim Peters <tim@ksr.com> said:
>
> t> The problem I hit is that I want to write a "substitute" function that
> t> takes the string and does the substitution, but once I cross the caller/
> t> callee boundary I can't get at the caller's namespaces. So substituting
> t> for names of ordinary variables becomes a real puzzler, short of
> t> explicitly building and passing a shadow dict of "interesting" names in
> t> the caller. Got a better idea in mind?
>
> Does my suggestion above help?
>

And, although I posted an 'upglobal' function for Tim, I didn't read
closely WHAT *exactly* he wanted it for, or I would have suggested
THEN that the dictionary ought to be an explicit argument. You might
JUST as likely want to substitute from a special (user-created)
symbol-table dict, as you would from the variables in the namspace
__dict__.

BUT:
Unless the dictionary values are all strings, they ought to have
some optional format+lenght specifiers in the syntax. Even if they
ARE strings, it would be nice to be able to specify the size of the
field.

'%02(day)/%02(month)/%02(year)'

would *almost* work -- except for floating point formats :-(

As long as we're all digging down into our wish lists, maybe
someone can come up with a syntax scheme that will allow both
numeric printf style format specification, and some sort of
template substitution that preserves the column alignment between
the format string and the output string.

-- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU> --
-- UVA Department of Molecular Physiology and Biological Physics --
-- Box 449 Health Science Center Charlottesville,VA 22908 --
[ "Cognitive Science is where Philosophy goes when it dies ...
if it hasn't been good!" - Jerry Fodor ]