Newbie can't figure out documentation practices
Fernando Perez
fperez528 at yahoo.com
Fri May 9 15:48:57 EDT 2003
Aahz wrote:
> There really isn't a good solution to this problem because you're mixing
> up multiple namespaces. You could come up with a decent solution by
> using a function call that took a string argument, a default dict
> (locals()), plus keyword-named dicts, and then doing your own
> interpolation. I.e.:
>
> print interpolate('''
> var x = $x
> var y = $y
> var self.z = $self.z
> fun x+y+self.z = $x+$y+$self.z
> var z from other object = $other.z
> z from self plus other = $self.z + $other.z
> ''',
> locals(),
> self=self,
> other=other
> )
This is more or less what Ka-Ping Yee's Itpl class does, which I actually
use. So my whining is about the language itself, not the impossibility of
writing a solution.
> But I don't think this need is common enough in Python to make it part
> of the language definition. You might look at helping to update PEP 215.
Been there, done that. I like to bring this one up about once a year, when
I'm too tired to really think :) But it never seems to get very far. Most
python users seem perfectly happy with the current interpolation behavior
(or using homebrewed solutions), so I'm obviously in the minority.
Cheers,
f
More information about the Python-list
mailing list