<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python 2 Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/python-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/python-2/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Wed, 10 Jul 2019 12:51:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Python 3  &#8211; there shall be just int</title>
		<link>https://creatronix.de/python-3-there-shall-be-just-int/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Mon, 14 Aug 2017 14:54:47 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[long]]></category>
		<category><![CDATA[python 2]]></category>
		<category><![CDATA[python 3]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=984</guid>

					<description><![CDATA[<p>Trying to contribute to the Flask plugin flask-login I just added these lines: if isinstance(duration, (int, long)): duration = timedelta(seconds=duration) Looking quite plausible, isn&#8217;t it? But lo and behold: it doesn&#8217;t work under Python 3.x. Dang! The reason: Python 2 has two integer types: int and long. In Python 3 there is only int, which&#8230;</p>
<p>The post <a href="https://creatronix.de/python-3-there-shall-be-just-int/">Python 3  &#8211; there shall be just int</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Trying to contribute to the Flask plugin <a href="https://github.com/maxcountryman/flask-login">flask-login</a> I just added these lines:</p>
<pre>if isinstance(duration, (int, long)):
    duration = timedelta(seconds=duration)</pre>
<p>Looking quite plausible, isn&#8217;t it? But lo and behold: it doesn&#8217;t work under Python 3.x. Dang!</p>
<p>The reason: Python 2 has two integer types: int and long. In Python 3 there is only int, which makes it necessary to distinguish between these two major versions. I&#8217;ve found a <a href="http://python3porting.com/differences.html">nice page</a> which deals with this issue. Here is what You must do to make it work in both Python 2 and 3:</p>
<pre><span class="kn">import</span> <span class="nn">sys</span>
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span> <span class="o">&lt;</span> <span class="p">(</span><span class="mi">3</span><span class="p">,):</span>
    i<span class="n">nteger_types</span> <span class="o">=</span> <span class="p">(</span><span class="nb">int</span><span class="p">,</span> <span class="nb">long</span><span class="p">,)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="n">integer_types</span> <span class="o">=</span> <span class="p">(</span><span class="nb">int</span><span class="p">,)</span>

<span class="nb">isinstance</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">integer_types</span><span class="p">)</span></pre>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/python-3-there-shall-be-just-int/">Python 3  &#8211; there shall be just int</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
