<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-584650982266257686</id><updated>2012-01-04T01:41:58.847-05:00</updated><title type='text'>Python 3.0 for CSE 231</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://python30.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-584650982266257686.post-4578568856754852901</id><published>2009-05-11T11:31:00.010-04:00</published><updated>2009-06-11T15:14:01.959-04:00</updated><title type='text'>Python 3.1 - get ready</title><content type='html'>Python 3.1 is in beta testing now.  The changes can be found &lt;a href="http://docs.python.org/dev/py3k/whatsnew/3.1.html"&gt;here&lt;/a&gt;, but I'll post a quick summary:&lt;br /&gt;&lt;br /&gt;Ordered dictionaries: &lt;a href="http://www.cse.msu.edu/%7Ecse231/Examples/CoursePack/Python/29-sortableDict/"&gt;Example 29&lt;/a&gt; provides us with a &lt;span style=";font-family:courier new;font-size:85%;"  &gt;SortableDict&lt;/span&gt; class, found in the &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;collections&lt;/span&gt;&lt;/span&gt; module.  What Python 3.1 gives us is a little different, though.  It just keeps the order that you passed in the items.  In addition to all of the normal &lt;span style=";font-family:courier new;font-size:85%;"  &gt;dict&lt;/span&gt; methods, this new class has a method &lt;span style=";font-family:courier new;font-size:85%;"  &gt;OrderedDict.popitem(last=&lt;span style="color: rgb(0, 0, 0);"&gt;True&lt;/span&gt;)&lt;/span&gt; that will pop the last (or first, if last is set to False) item off of the object, much like &lt;span style=";font-family:courier new;font-size:85%;"  &gt;list.pop()&lt;/span&gt;.  Note that if you change the value of an item, the order will not change.  If you remove that item and then add it back in, the item will then go to the back.  Here's how to use the &lt;span style=";font-family:courier new;font-size:85%;"  &gt;OrderedDict&lt;/span&gt; class in 3.1 (using Dr. Punch's &lt;span style=";font-family:courier new;font-size:85%;"  &gt;example29.demo()&lt;/span&gt; example values):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msu.edu/%7Eamentajo/orderedDict.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 75px;" src="http://www.msu.edu/%7Eamentajo/orderedDict.png" alt="" border="0" /&gt;&lt;/a&gt;And the output...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.msu.edu/%7Eamentajo/orderedDictOut.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 400px; height: 96px;" src="http://www.msu.edu/%7Eamentajo/orderedDictOut.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;String formatting, the new way.  As you probably have read in my first post, the &lt;span style="font-family:courier new;"&gt;format&lt;/span&gt; method on strings is the preferred way to format strings... but it seems kind of silly to number each format part if you're just going in order (like we're used to with the % operator):&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;"I asked my friend {0}, and I asked my friend {1}; they said it was {2}!".format("Joe", "Jake", "fhqwhgads")&lt;/span&gt;&lt;br /&gt;Well now, with Python 3.1 (RC1 is out), you can do this:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;"I asked my friend {}, and I asked my friend {}; they said it was {}!".format("Joe", "Jake", "fhqwhgads")&lt;/span&gt;&lt;br /&gt;and you will get the same formatted output.  Of course, the numbering method will still work (and is still necessary if you want to be playing with the order of the format strings).&lt;br /&gt;&lt;br /&gt;Also format-related, check this out (the comma means to add decimal separators, everything else has been around since 2.6/3.0... "0" says the first argument to format, ":" means to do manipulation, ".2" means 2-precision, "f" means to "coerce" to float):&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; "{0:,.2f}".format(123456789)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;'123,456,789.00'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That's right, human-readable decimals with string formatting!&lt;br /&gt;(Combine this new change with the previous one and you get this:)&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; "{:,.2f}".format(123456789)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;'123,456,789.00'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;More to come when I get time.&lt;br /&gt;&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/584650982266257686-4578568856754852901?l=python30.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python30.blogspot.com/feeds/4578568856754852901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=584650982266257686&amp;postID=4578568856754852901' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/4578568856754852901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/4578568856754852901'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/2009/05/python-31-get-ready.html' title='Python 3.1 - get ready'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-584650982266257686.post-4480135346884714518</id><published>2008-12-04T08:13:00.002-05:00</published><updated>2008-12-04T08:27:53.321-05:00</updated><title type='text'>Py3k is final.</title><content type='html'>As of 11:59pm EST, Python 3.0 has been released.  If you're planning on upgrading, there is a very good chance that the "2to3" tool released with it (I believe it came with Python 2.6 as well) will be able to fix your code that worked with 2.x to again work with 3.0.  Of course, make sure that it works in 2.x before running 2to3, or you might have a tough time figuring out what's wrong with your program.&lt;br /&gt;&lt;br /&gt;See the first post of this blog for a list of the major things different from the upgrade.&lt;br /&gt;&lt;br /&gt;Most important things:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;raw_input()&lt;/span&gt;&lt;/span&gt; is no longer &lt;span style="font-family: courier new;font-size:85%;" &gt;raw_&lt;/span&gt; anymore, and just became &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;input()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;print&lt;/span&gt; is now a FUNCTION, not a statement.  That means parentheses.  (Get your fingers used to it now!)  &lt;span style="font-family: courier new;font-size:85%;" &gt;print(x)&lt;/span&gt;, not &lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;print x&lt;/span&gt;&lt;/span&gt;.&lt;br /&gt;integer division (&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;int / int&lt;/span&gt;&lt;/span&gt;) returns a float!  (&lt;span style="font-family: courier new;font-size:85%;" &gt;int // int&lt;/span&gt; does the classic thing).  Also longs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/584650982266257686-4480135346884714518?l=python30.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python30.blogspot.com/feeds/4480135346884714518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=584650982266257686&amp;postID=4480135346884714518' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/4480135346884714518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/4480135346884714518'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/2008/12/py3k-is-final.html' title='Py3k is final.'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-584650982266257686.post-4709363655500810150</id><published>2008-11-20T09:15:00.000-05:00</published><updated>2008-11-20T09:16:49.890-05:00</updated><title type='text'>Coercion in Py3k</title><content type='html'>In Python 3.0, as Dr. Punch has hinted at in class today, coerce() and all its friends are removed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/584650982266257686-4709363655500810150?l=python30.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python30.blogspot.com/feeds/4709363655500810150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=584650982266257686&amp;postID=4709363655500810150' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/4709363655500810150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/4709363655500810150'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/2008/11/coercion-in-py3k.html' title='Coercion in Py3k'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-584650982266257686.post-6657639860080463029</id><published>2008-11-06T08:57:00.000-05:00</published><updated>2008-11-06T09:00:52.463-05:00</updated><title type='text'>NumPy in Python 3.0</title><content type='html'>Today, Dr. Punch talked about NumPy.  Note that this module is not available in Python 3.0 yet.  My hopes are that this is available by the time Py3k is released, but it is rather possible that we will have to go without it.&lt;br /&gt;&lt;br /&gt;Also, note that I have finished testing all the class examples with the 2to3 script.  Go ahead and read what's different now!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/584650982266257686-6657639860080463029?l=python30.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python30.blogspot.com/feeds/6657639860080463029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=584650982266257686&amp;postID=6657639860080463029' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/6657639860080463029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/6657639860080463029'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/2008/11/numpy-in-python-30.html' title='NumPy in Python 3.0'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-584650982266257686.post-26466730664460854</id><published>2008-10-16T10:53:00.000-04:00</published><updated>2008-10-16T11:02:42.983-04:00</updated><title type='text'>Dictionary Methods</title><content type='html'>Straight from the list of changes in 3.0 regarding dictionary methods:&lt;br /&gt;&lt;br /&gt;&lt;tt class="xref docutils literal"&gt;&lt;span class="pre"&gt;dict&lt;/span&gt;&lt;/tt&gt; methods &lt;tt class="xref docutils literal"&gt;&lt;span class="pre"&gt;dict.keys()&lt;/span&gt;&lt;/tt&gt;, &lt;tt class="xref docutils literal"&gt;&lt;span class="pre"&gt;dict.items()&lt;/span&gt;&lt;/tt&gt; and &lt;tt class="xref docutils literal"&gt;&lt;span class="pre"&gt;dict.values()&lt;/span&gt;&lt;/tt&gt; return views instead of lists.  For example, this no longer works: &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;k&lt;/span&gt; &lt;span class="pre"&gt;=&lt;/span&gt; &lt;span class="pre"&gt;d.keys();&lt;/span&gt; &lt;span class="pre"&gt;k.sort()&lt;/span&gt;&lt;/tt&gt;.  Use &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;k&lt;/span&gt; &lt;span class="pre"&gt;=&lt;/span&gt; &lt;span class="pre"&gt;sorted(d)&lt;/span&gt;&lt;/tt&gt; instead.&lt;br /&gt;&lt;br /&gt;Never fear!  These methods can still give you lists, by using the list() function on them.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;{'k':49,'g':500}.values() =&gt; [49,500]&lt;/span&gt; in 2.x&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;list({'k':49,'g':500}.values()) =&gt; [49,500]&lt;/span&gt; in 3.0.&lt;br /&gt;&lt;br /&gt;This refactoring is included with the 2to3 shell script included with version 2.6 and version 3.0RC1&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/584650982266257686-26466730664460854?l=python30.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python30.blogspot.com/feeds/26466730664460854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=584650982266257686&amp;postID=26466730664460854' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/26466730664460854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/26466730664460854'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/2008/10/dictionary-methods.html' title='Dictionary Methods'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-584650982266257686.post-7205717263099931898</id><published>2008-10-07T09:07:00.000-04:00</published><updated>2008-11-03T12:45:16.515-05:00</updated><title type='text'>Python 3.0: What affects us?</title><content type='html'>I've built Python 3.0 RC1 (First Release Candidate) to test out what it's going to do to our projects.  This blog is specifically dedicated to a list of the changes that affect us.  I will update it as I find more things (I'm going to literally go through all my projects and all the class code examples and say what doesn't work.)&lt;br /&gt;&lt;br /&gt;If you have any questions about your particular projects / code snippets, you can send them to me at &lt;a href="mailto:amentajo@msu.edu"&gt;amentajo@msu.edu&lt;/a&gt; or simply post as a comment here.  PLEASE don't send me the current working project or any significant portions of it.  (Project 10 now...)&lt;br /&gt;&lt;br /&gt;I'm willing to put my time into testing anything sent to me, so don't hesitate to send me things to test!&lt;br /&gt;&lt;br /&gt;Python 3.0 RC1 incompatibilities:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;--strings&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;----String formatting with the % operator is done away with, and replaced by a &lt;span style="font-family:courier new;"&gt;format()&lt;/span&gt; method for strings.&lt;span style="font-family:verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-family:courier new;font-size:78%;"  &gt;'Hello, %s' % ('world')&lt;/span&gt;&lt;span style="font-size:78%;"&gt; has turned into &lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);font-family:courier new;font-size:78%;"  &gt;'Hello, {0}'.format('world')&lt;/span&gt;&lt;span style="font-size:78%;"&gt;.  In general, it looks like&lt;span style="font-family:verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 102, 0);font-family:courier new;font-size:78%;"  &gt;'Sometext {n}'.format('a','b','c','d')&lt;/span&gt;&lt;span style="font-size:78%;"&gt; where the {n} refers to the index of the tuple passed to format().  See &lt;a href="http://svn.python.org/projects/peps/trunk/pep-3101.txt"&gt;the official readme&lt;/a&gt; for more details on this matter.&lt;/span&gt;  It has been confirmed that the previous statement is false.  In 3.0, &lt;span style="color: rgb(0, 153, 0);font-family:courier new;font-size:85%;"  &gt;print('Hello %s' % ('world'))&lt;/span&gt; works, as do all other implementations of the % formatting character we have learned in class. (See comment below about &lt;span style=";font-family:courier new;font-size:85%;"  &gt;print()&lt;/span&gt;).  My previous confusion was due to the fact that print is a function now.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;--integers&lt;/span&gt;&lt;br /&gt;----integer division returns a float... &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;1/2 =&gt; 0.5&lt;/span&gt;&lt;/span&gt;, &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;1//2 =&gt; 0&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;----long integers are now just integers, and there is no max length&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;--print:&lt;/span&gt;&lt;br /&gt;----&lt;span style=";font-family:courier new;font-size:85%;"  &gt;print&lt;/span&gt; no longer works 'without parentheses'.  You must use &lt;span style="color: rgb(255, 102, 0);"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;span style="color: rgb(0, 102, 0);font-family:courier new;font-size:85%;"  &gt;print("Hello World")&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.&lt;/span&gt;&lt;/span&gt; &lt;/span&gt;&lt;span style="color: rgb(255, 0, 0);font-family:courier new;font-size:85%;"  &gt;print "Hello World"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; will no longer work.&lt;/span&gt;  This is because print has been changed from a statement into a function: &lt;span style="color: rgb(0, 102, 0);font-family:courier new;font-size:85%;"  &gt;print(x)&lt;/span&gt; rather than &lt;span style="color: rgb(255, 0, 0);font-family:courier new;font-size:85%;"  &gt;print x&lt;/span&gt;.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;--raw_input:&lt;/span&gt;&lt;br /&gt;----&lt;span style="color: rgb(255, 0, 0);"&gt;raw_input()&lt;/span&gt; has been replaced with &lt;span style="color: rgb(0, 102, 0);"&gt;input()&lt;/span&gt;, which appears to work exactly the same.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;--range:&lt;/span&gt;&lt;br /&gt;----&lt;span style="color: rgb(0, 102, 0);font-family:courier new;font-size:85%;"  &gt;range()&lt;/span&gt; now returns an iterable instead of a list.  That is to say,&lt;span style="color: rgb(0, 102, 0);"&gt; &lt;span style=";font-family:courier new;font-size:85%;"  &gt;x = range(1,10)&lt;/span&gt;&lt;/span&gt; will return &lt;span style="color: rgb(0, 0, 153);font-family:courier new;font-size:85%;"  &gt;range(1,10)&lt;/span&gt; when &lt;span style="font-family:courier new;"&gt;x&lt;/span&gt; is called, but&lt;span style="color: rgb(0, 102, 0);"&gt; &lt;span style=";font-family:courier new;font-size:85%;"  &gt;for x in range(1,10): print (x, end = '')&lt;/span&gt;&lt;/span&gt; will print &lt;span style="color: rgb(0, 0, 153);"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;123456789&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;.  (This is the behaviour of a function that exists in 2.5 called &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;xrange()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;, which no longer exists in 3.0)&lt;br /&gt;&lt;br /&gt;Specific tests of Class Code Examples (python 3.0 and 2.6 come with a script called '2to3' that refactors certain lines of 2.x code to work with 3.0.  I tested the examples after running 2to3 on them, and these are the results):&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;01-04:&lt;br /&gt;&lt;/span&gt;&lt;span&gt;fixed with 2to3...&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;05-haiku:&lt;/span&gt;&lt;br /&gt;not fixed with 2to3... error at line 6, "NameError: name 'file' is not defined"  This appears to be because in 3.0, various builtins were removed, including file().  Not sure what a workaround may be.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;06-10:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;11-password:&lt;/span&gt;&lt;br /&gt;almost fixed with 2to3...  change the variable name input to something else, as input() is now a function.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;11.5-Palindromes:&lt;/span&gt;&lt;br /&gt;not fixed with 2to3... multiple functions do not operate properly.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;12-simpleLists:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;13-forExample:&lt;/span&gt;&lt;br /&gt;fixed with 2to3 and changing &lt;span style="color: rgb(255, 0, 0);"&gt;range(1-11)&lt;/span&gt; to &lt;span style="color: rgb(0, 153, 0);"&gt;range(1,11)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;14-perfectNumbers:&lt;/span&gt;&lt;br /&gt;fixed with 2to3, but be careful - the commented lines of print statements will NOT run if uncommented after 2to3.  Please make all changes to original 2.x modules before running 2to3, and rerun it every time you make a change.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;15-16B:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;16C-mileagePuz:&lt;/span&gt;&lt;br /&gt;fixed with 2to3... note that the time output for 3.0 appears to be approximately 25% faster than the same module in 2.6.  (running Ubuntu Linux 8.04, Hardy Heron (linux kernel 2.6.24-21-generic), Intel Core 2 Duo (1.00GHz * 2), the averages of the two are 300ms in 3.0, 400ms in 2.6.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;17-19:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;20-sets:&lt;/span&gt;&lt;br /&gt;simpleSets.py is broken in 2.5 and 2.6: lists are unhashable.  2to3 keeps this error.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;21-dicts:&lt;br /&gt;&lt;/span&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;21.5-funcParams:&lt;br /&gt;&lt;/span&gt;not fixed with 2to3, but very fixable.  change commas in print functions to %( and close parentheses at the end.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;22-classes:&lt;/span&gt;&lt;br /&gt;fixed with 2to3... previously reported as broken, but works as intended...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;23-scope:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;24-note:&lt;/span&gt;&lt;br /&gt;not fixed with 2to3... must delete the s.print call, or define the method (print is now a function, not a statement)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;25-27:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;28-expansion:&lt;/span&gt;&lt;br /&gt;almost fixed with 2to3... line 35 is malindented.  Add another space there.  Also, make sure example 27's Rational.py is in PYTHONPATH or you will get an ImportError.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;29,30:&lt;/span&gt;&lt;br /&gt;fixed with 2to3&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;31-PythonArray:&lt;/span&gt;&lt;br /&gt;not fixed with 2to3... NumPy is not 3.x ready.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;32-exceptionExamples:&lt;/span&gt;&lt;br /&gt;not all fixed with 2to3...&lt;br /&gt;&lt;span style="font-style: italic;"&gt;fullException.py:&lt;/span&gt;&lt;br /&gt;types that were once "file" are now class objects io.TextIOWrapper.  Fix by importing the io module then changing line 23 to:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        if type(fs)== io.TextIOWrapper:&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-family:georgia;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-style: italic;font-family:georgia;" &gt;exceptionFlow.py:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;&lt;span style="font-family:georgia;"&gt;fixed with 2to3...&lt;br /&gt;&lt;span style="font-style: italic;"&gt;raise.py:&lt;/span&gt;&lt;br /&gt;working, but be careful of the name conflict with 'raise'.  No importing raise or anything from raise, but you can run it otherwise.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;33-sort_and_search:&lt;/span&gt;&lt;br /&gt;sort works with 2to3, but search needs one adjustment: since int division returns a float, line 26 needs to be converted to an int with the int() function after refactoring.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;34-scriptExample:&lt;/span&gt;&lt;br /&gt;fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;35-_testing:&lt;/span&gt;&lt;br /&gt;doctestExample.py: problems with long integers: long() is now named int() and L suffixes are removed in 3.0.&lt;br /&gt;unittestExample.py: fixed with 2to3...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;36-_PythonToC++:&lt;/span&gt;&lt;br /&gt;irrelevant; the dateClass.py module is in example 22.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="mailto:amentajo@msu.edu"&gt;amentajo@msu.edu&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/584650982266257686-7205717263099931898?l=python30.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://python30.blogspot.com/feeds/7205717263099931898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=584650982266257686&amp;postID=7205717263099931898' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/7205717263099931898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/584650982266257686/posts/default/7205717263099931898'/><link rel='alternate' type='text/html' href='http://python30.blogspot.com/2008/10/python-30-what-affects-us.html' title='Python 3.0: What affects us?'/><author><name>Joe</name><uri>http://www.blogger.com/profile/06860129150617595015</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='26' height='32' src='http://2.bp.blogspot.com/_mlSxYpKD0k8/SOtnP4lhxdI/AAAAAAAAAAM/sPApq0Pxl94/S220/mein-formal.jpg'/></author><thr:total>2</thr:total></entry></feed>
