On Mon, 2006-04-03 at 11:13 -0500, Ian Bicking wrote:

> assert path.startswith(prefix), (
>      "%r should start with %r" % (path, prefix))
> assert path.startswith(prefix), (
>      $"${repr(path)} should start with ${repr(prefix)}")
> assert path.startswith(prefix), (
>      "$path should start with $prefix".substitute(
>      path=repr(path), prefix=repr(prefix))

The second example is why I added sys._getframe().  In my i18n code, I
wanted to do things like this (rewritten for $-string style):

print _("$user is not a member of the $listname mailing list")

and it would Just Work.  Now, the trick is that in the same function,
just before the print line, you'd have code like this (pseudocoded):

user = utils.websafe(form.get('user'))
listname = mlist.get_name()

So _() does a sys._getframe() to dig the locals out of the calling
function, and does the substitutions from there.  So, if your
applications isn't i18n, I could see the use for a format() global, but
while I'd probably want the behavior I just described, you might not, so
I'm not sure we could write a format() builtin that would be useful to
us both.

-Barry

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to