string interpolation (was: Newbie can't figure out documentation practices)
Fernando Perez
fperez528 at yahoo.com
Fri May 9 16:08:05 EDT 2003
Fernando Perez wrote:
> Personally I would argue that for a newbie, the fact that
>
> print "x=%(x)s" % locals()
>
> works
>
> while
>
> print "self.x=%(self.x)s" % locals()
>
> doesn't, and that the solution requires _getframe, should be seen as a
> language wart. _getframe is a hackish feature (which I use a lot, in fact
Just to clarify: _one_ solution, the one given in I.v.d.Kleyn's nice
example. J. Collins' does not use _getframe, at the expense of requiring
locals/globals to be passed in explicitly.
Cheers,
f
More information about the Python-list
mailing list