2001 Enchancement Wishlist
Fredrik Lundh
fredrik at effbot.org
Fri Dec 29 16:31:29 EST 2000
Raymond Hettinger wrote:
> 2. There is already a PEP to extend the eval() function which is currently
> limited to dictionaries. The goal is to accept any object defining
> __getitem__() so that any mapping object can be used to specify the
> globals and locals. I recommend that we extend the same courtesy to
> the % string formatting operator. For example:
>
> print "Spam with %s, eggs, and spam" % aUserDictionary
this already works -- if you use dictionary formatting
operators:
class D:
def __getitem__(self, name):
return name
d = D()
print "%(spam)s %(egg(10))s" % d
# prints spam egg(10)
</F>
More information about the Python-list
mailing list