[Python-Dev] Re: Update PEP 292 (original) (raw)
Barry Warsaw barry at python.org
Wed Aug 11 15:55:37 CEST 2004
- Previous message: [Python-Dev] Re: Update PEP 292
- Next message: [Python-Dev] Re: Re: Update PEP 292
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 2004-08-11 at 08:06, Fernando Perez wrote:
If I understood things correctly, this proposal will not allow the evaluation of any kind of expression, including attributes. With the existing interpolation system, the following happens:
In [2]: print 'sys.platform is: %(sys.platform)s' % locals() --------------------------------------------------------------------------- KeyError Traceback (most recent call last) ? KeyError: sys.platform
You don't mean the 'existing' interpolation system, because this obviously doesn't work in Python today, although with a fancy enough implementation of 'locals()', it could. That actually doesn't change much with PEP 292. I specifically designed it so that you could subclass from template, so as to accept the extended placeholder syntax (i.e. dots), and then implement a mapping-like class to do the lookups in any namespace you want. In fact, my earlier implementation contained such a class, but it was deemed too complex to win the name 'simpler' so it was left out of the library. It's a trivial amount of code and my own personal use case has a need for such a feature.
-Barry
-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20040811/ca79d64c/attachment-0001.pgp
- Previous message: [Python-Dev] Re: Update PEP 292
- Next message: [Python-Dev] Re: Re: Update PEP 292
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]