Newbie can't figure out documentation practices
sismex01 at hebmex.com
sismex01 at hebmex.com
Fri May 9 13:23:49 EDT 2003
>
> Ok, time for my yearly rant on interpolation ;) Can anyone
> tell me how to do cleanly something like (using perl-like
> syntax to indicate my intent, this isn't real code):
>
> print """
> 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
> """ % ????
>
Hmmm... I'd first:
>>> def D(**args): return args
and then:
print """
var x = %(x)s
var y = %(y)s
var self.z = %(self_z)s
fun x+y+self.z = %(x)s+%(y)s+%(self_z)s
var z from other object = %(other_z)s
z from self plus other = %(self_z)s + %(other_z)s
""" % D(x=..., y=..., self_z=self.z, other_z=other.z)
But, I think, I suspect that you don't like %(...)s
>
> I've been told to write the above with tons of print
> statements (one per line) and even more quotemarks:
>
> print 'x=',x,'self.z=',self.z,...
>
ewwww....
> But I _hate_ that kind of output for anything longer than
> two or three lines. It's nearly impossible to read smoothly
> something which is say 50 lines of the above with many variables.
>
> Cheers, and TIA,
>
> f.
>
-gus
More information about the Python-list
mailing list