Alan Gauld wrote:
"Ray Parrish" <c...@cmc.net> wrote
print "A %s with dimensions %sx%s has an area of %s." % (choice, height, width, width*height)

Isn't it a little more understandable to use a construct like the following?

print "The area of a " + Choice + "is " str(Width) + " x " +
str(Height) + " equals " + str(Width * Height) + " square feet"

It depends on where you come from.
Those of us brought up on C or COBOL are used to separating the presentation from the data. Those brought up with PASCAL and BASIC are used to iterleaving data with presentation.

One thing - you don't need all the str() calls in your example, print already calls str() for you. Also comma separators are better than + signs since the plus operation on strings is quite expensive - you create a new string for each addition.

HTH,
Thanks for the tips. If I understand you correctly I can do the call this way? -

print "The area of ", Choice, " is ", Width, " x ", Height, " equals ", (Width * Height), " square feet"

That eliminates the redundancy, and is quite readable to me. I like it. 8-)

Later, Ray Parrish

--
Linux dpkg Software Report script set..
http://www.rayslinks.com/LinuxdpkgSoftwareReport.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to