{"id":14305,"date":"2020-08-09T11:54:08","date_gmt":"2020-08-09T11:54:08","guid":{"rendered":"https:\/\/www.jurn.link\/dazposer\/?p=14305"},"modified":"2025-06-25T13:18:30","modified_gmt":"2025-06-25T13:18:30","slug":"python-2-to-3","status":"publish","type":"post","link":"https:\/\/jurn.link\/dazposer\/index.php\/2020\/08\/09\/python-2-to-3\/","title":{"rendered":"Python 2 to 3"},"content":{"rendered":"<p>Here are some links that may possibly useful as a quickstart for the Poser 11 to Poser 12 leap, and the need to tweak PoserPython scripts so they conform with Python version 3.<\/p>\n<p><strong>1.<\/strong> The official <a href=\"https:\/\/docs.python.org\/3\/library\/2to3.html\">2to3 &#8211; Automated Python 2 to 3 code translation<\/a>.<\/p>\n<p><strong>2.<\/strong> <a href=\"http:\/\/python-future.org\/automatic_conversion.html\">Futurize<\/a> calls in 2to3 and uses it to do automatic conversion of Poser 2 to Poser 3&#8230;<\/p>\n<blockquote><p>The futurize script passes Python 2 code through all the appropriate fixers to turn it into valid Python 3 code, and then adds __future__ and future package imports to re-enable compatibility with Python 2.<\/p><\/blockquote>\n<p><strong>3.<\/strong> <a href=\"https:\/\/python-modernize.readthedocs.io\/en\/latest\/\">Python-Modernize<\/a> also calls in 2to3 and uses it to make&#8230;<\/p>\n<blockquote><p>a very thin wrapper around lib2to3 to utilize it to make Python 2 code more modern with the intention of eventually porting it over to Python 3.<\/p><\/blockquote>\n<hr>\n<p><strong>What breaks?<\/strong>  <\/p>\n<p>* It seems that the command <strong>print<\/strong> is handled differently in Python 3 scripts.  So are <strong>strings<\/strong>.  The way that <strong>iterated lists<\/strong> are done also seem to have changed.  There&#8217;s a <a href=\"https:\/\/sebastianraschka.com\/Articles\/2014_python_2_3_key_diff.html\">comparison page here<\/a>.<\/p>\n<p>* Standard library Python &#8216;packages&#8217; or &#8216;modules&#8217;, of the sort called in by a simple name placed at the top of some scripts, have been moved or renamed or lower-cased. There&#8217;s a <a href=\"http:\/\/python3porting.com\/stdlib.html\">list<\/a> on which <strong>Tkinter<\/strong> is now <strong>tkinter<\/strong>, and <strong>SimpleDialog<\/strong> is now <strong>tkinter.simpledialog<\/strong>. Tkinter is only relevant for Windows users, as Apple bans it from the Mac. It&#8217;s used in PoserPython to make user interfaces for scripts. I don&#8217;t recognise any of the others.<\/p>\n<p>* Not only will Tkinter scripts need to have their in-script Tkinter &#8216;module call&#8217; lower-cased to read tkinter, but on Poser 12 we may also have to download the latest Python and &#8220;then copy the tkinter directory, and the tcl8.6 and tk8.6 directories to the runtime\/python\/lib directory&#8221; of Poser 12.<\/p>\n<p>* Some &#8216;packages&#8217; or &#8216;modules&#8217;, of the sort seen being called in at the top of some scripts, have been <a href=\"http:\/\/python3porting.com\/stdlib.html\">dropped altogether<\/a> from Python 3.  <strong>Canvas<\/strong> and <strong>user<\/strong> are the only ones that look vaguely familiar to me from my looking at various PoserPython scripts.  I&#8217;m not a &#8216;write it from scratch&#8217; coder, just a code-hacker and tweaker and grafter who can bash something together and test it until it works.  Proper coders may have more to add on the practicalities of getting a broken script from Python 2 to 3 &mdash; and thus to Poser 12. Possibly you might use an AI coding assistant.<\/p>\n<p>* Apparently you can&#8217;t mix tabs and spaces in scripts, in version 3.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are some links that may possibly useful as a quickstart for the Poser 11 to Poser 12 leap, and the need to tweak PoserPython scripts so they conform with Python version 3. 1. The official 2to3 &#8211; Automated Python 2 to 3 code translation. 2. Futurize calls in 2to3 and uses it to do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,26,27],"tags":[],"class_list":["post-14305","post","type-post","status-publish","format-standard","hentry","category-poser","category-poser-12","category-python-scripts"],"_links":{"self":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts\/14305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/comments?post=14305"}],"version-history":[{"count":2,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts\/14305\/revisions"}],"predecessor-version":[{"id":23480,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/posts\/14305\/revisions\/23480"}],"wp:attachment":[{"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/media?parent=14305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/categories?post=14305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jurn.link\/dazposer\/index.php\/wp-json\/wp\/v2\/tags?post=14305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}