<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Printing in Python 3.0</title>
	<link>http://efford.org/blog/archives/34</link>
	<description>Random musings on Python, software engineering, the web &#038; other stuff</description>
	<pubDate>Thu, 21 Aug 2008 14:42:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: Nick</title>
		<link>http://efford.org/blog/archives/34#comment-30289</link>
		<pubDate>Tue, 01 Apr 2008 13:45:16 +0000</pubDate>
		<guid>http://efford.org/blog/archives/34#comment-30289</guid>
					<description>Some good points Jayce.  I expect that plenty of folk will be opposed to the idea of introducing a new built-in, for understandable reasons.

However, in a language that prides itself on clarity, and that is prepared to break backwards compatibility to the point that "hello world" no longer works in order to achieve this, I confess to being a little disappointing that a more direct, less clumsy approach to formatted printing isn't yet available.

Don't get me wrong; there's a number of things about the new approach to string formatting that I like.  It is more flexible and powerful, for one.  And I think I prefer {0}, {1}, etc, as a placeholder syntax.  What I don't really like is the relative unreadability of code like this:

print("Content-type: {0[.mp4]}".format(mimetypes.types_map))

OK, you can rewrite this as

format_string = "Content-type: {0[.mp4]}"
print(format_string.format(mimetypes.types_map))

But I think a printf in this case is even easier to read.</description>
		<content:encoded><![CDATA[<p>Some good points Jayce.  I expect that plenty of folk will be opposed to the idea of introducing a new built-in, for understandable reasons.</p>
<p>However, in a language that prides itself on clarity, and that is prepared to break backwards compatibility to the point that &#8220;hello world&#8221; no longer works in order to achieve this, I confess to being a little disappointing that a more direct, less clumsy approach to formatted printing isn&#8217;t yet available.</p>
<p>Don&#8217;t get me wrong; there&#8217;s a number of things about the new approach to string formatting that I like.  It is more flexible and powerful, for one.  And I think I prefer {0}, {1}, etc, as a placeholder syntax.  What I don&#8217;t really like is the relative unreadability of code like this:</p>
<p>print(&#8221;Content-type: {0[.mp4]}&#8221;.format(mimetypes.types_map))</p>
<p>OK, you can rewrite this as</p>
<p>format_string = &#8220;Content-type: {0[.mp4]}&#8221;<br />
print(format_string.format(mimetypes.types_map))</p>
<p>But I think a printf in this case is even easier to read.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jayce</title>
		<link>http://efford.org/blog/archives/34#comment-30116</link>
		<pubDate>Sun, 30 Mar 2008 23:34:25 +0000</pubDate>
		<guid>http://efford.org/blog/archives/34#comment-30116</guid>
					<description>Ideally, to maintain the uniformity that the new print functions introduce, we would need to provide the same interface that print() provides.

Say, something like this should work.

printf(format_string, blah, blah, file=stderr)

I haven't looked into all the options of Python 3.0's format function, but if there is a conflict, in the key-word arguments with that of the print function, it could get tricky.

Without a printf(), we can still write, something that looks very similar:
print(format_string.format(blah, blah), file=stderr)

Without printf, we need to type ".format(" and its matching ")"; 9 more characters. 

The opinion on whether the savings is worth enough to add another built-in is bound to differ from developer to developer. I think, we still have a few months more to wait and see. :-)</description>
		<content:encoded><![CDATA[<p>Ideally, to maintain the uniformity that the new print functions introduce, we would need to provide the same interface that print() provides.</p>
<p>Say, something like this should work.</p>
<p>printf(format_string, blah, blah, file=stderr)</p>
<p>I haven&#8217;t looked into all the options of Python 3.0&#8217;s format function, but if there is a conflict, in the key-word arguments with that of the print function, it could get tricky.</p>
<p>Without a printf(), we can still write, something that looks very similar:<br />
print(format_string.format(blah, blah), file=stderr)</p>
<p>Without printf, we need to type &#8220;.format(&#8221; and its matching &#8220;)&#8221;; 9 more characters. </p>
<p>The opinion on whether the savings is worth enough to add another built-in is bound to differ from developer to developer. I think, we still have a few months more to wait and see. <img src='http://efford.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
