[Python-Dev] extended print statement, uPre-PEP
Barry A. Warsaw
bwarsaw@beopen.com
Mon, 24 Jul 2000 01:45:18 -0400 (EDT)
| def lookup( query )
| regex=$"${person.lastname},${person.firstname}: .*${query}=(\w+)"
| ....
So let me try to guess what you mean here. I really have no idea if
I'm right. $"..." is some new type of syntax that says to do magic
name lookup and interpolation when creating the string.
person.lastname must be an attribute on some object bound to the
variable `person'. Where does `person' come from? I guess you'd use
the normal namespace rules, so if I saw this function in your code I'd
have to assume that person appears in the globals (because putting it
in builtins is bad form and I don't see it in the function's locals).
But you really don't need any of that new magic stuff or new syntax
(or is it a new string type?). The nugget of interesting new
functionality here is that your doing attribute lookup inside a string
interpolation, and /that/ might be a cool thing to have. E.g.
def lookup(query):
regex = '%(person.lastname)s,%(person.firstname)s: .*%(query)s=(\w+)' \
% vars()
seems reasonable to me, and doesn't add nearly as much new or magical
stuff as your example above.
-Barry