<?xml version="1.0" encoding="utf-8"?>

<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:cc="http://web.resource.org/cc/"
  xmlns="http://purl.org/rss/1.0/">

<channel rdf:about="https://www.garyrobinson.net/">
<title>Gary Robinson&#39;s Rants</title>
<link>https://www.garyrobinson.net/</link>
<description>Rants on Python, crypto, politics, music, and other assorted stuff.               </description>
<dc:language>en-US</dc:language>
<dc:creator></dc:creator>
<dc:date>2013-10-07T17:04:38-04:00</dc:date>
<admin:generatorAgent rdf:resource="http://www.typepad.com/" />


<items>
<rdf:Seq><rdf:li rdf:resource="https://www.garyrobinson.net/2013/10/i-love-python-and-have-posted-a-number-of-python-tips-on-this-blog-and-ive-been-involved-in-the-creation-of-sizable-web-sit.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2012/02/calculating-the-product-of-a-python-list.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2011/06/seleniums-webdriver-python-dealing-with-script-timeouts.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2009/10/non-blocking-raw_input-for-python.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2008/04/splitting-a-pyt.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2004/07/more_cleaning_u.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2004/04/cleaning_up_pyt.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2004/03/one_line_python.html" />
<rdf:li rdf:resource="https://www.garyrobinson.net/2004/03/python_singleto.html" />
</rdf:Seq>
</items>

</channel>

<item rdf:about="https://www.garyrobinson.net/2013/10/i-love-python-and-have-posted-a-number-of-python-tips-on-this-blog-and-ive-been-involved-in-the-creation-of-sizable-web-sit.html">
<title>Javascript and SPA&#39;s, as seen by a long-time Python developer</title>
<link>https://www.garyrobinson.net/2013/10/i-love-python-and-have-posted-a-number-of-python-tips-on-this-blog-and-ive-been-involved-in-the-creation-of-sizable-web-sit.html</link>
<description>I love Python and have posted a number of Python tips on this blog. And I&#39;ve been involved in the creation of sizable web sites using Django. But I&#39;ve come to feel that for many types of web sites, doing...</description>
<content:encoded>&lt;p&gt;I love &lt;a href=&quot;http://python.org&quot;&gt;Python&lt;/a&gt; and have posted a number of Python tips on this blog. And I&#39;ve been involved in the creation of sizable web sites using Django.&lt;/p&gt;
&lt;p&gt;But I&#39;ve come to feel that for many types of web sites, doing all the rendering on the server and shipping the rendered page to the browser is probably not be the best way to go. Certainly, I&#39;m not the first to come to that conclusion. Google Docs is a phenomenal example of what can be done in a &quot;single page app&quot; (SPA) rendered in the browser. There are many others.&lt;/p&gt;
&lt;p&gt;In the course of investigating the various technologies for creating SPA&#39;s, one thing I&#39;ve come to appreciate about that strategy is that you may not need much of a server at all. If you use something like &lt;a href=&quot;https://www.firebase.com&quot;&gt;Firebase&lt;/a&gt; for your database, you may need nothing more than a means of serving static html and JavaScript files on your server. And then you can use a CDN like &lt;a href=&quot;https://www.cloudflare.com&quot;&gt;CloudFlare&lt;/a&gt; to keep you online even if that server is &lt;a href=&quot;http://www.cloudflare.com/always-online&quot;&gt;temporarily down&lt;/a&gt;. All these factors together can eliminate an enormous amount of overhead in server administration.&lt;/p&gt;
&lt;p&gt;Eliminating such overhead seems like it could be very helpful for my goal of creating my next project entirely &lt;a href=&quot;http://www.garyrobinson.net/2012/04/update.html&quot;&gt;by myself&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately, JavaScript is (IMO) not nearly as nice a language as Python. But if used according to certain patterns, such as described in the famous &lt;a href=&quot;http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742&quot;&gt;JavaScript: The Good Parts&lt;/a&gt;, a lot of its deficiencies are mitigated, and then it&#39;s really not so bad. And most modern JavaScript libraries use the language in that way, so the ecosystem as a whole supports you in that.&lt;/p&gt;
&lt;p&gt;Javascript even has Python-like constructions such as &lt;a href=&quot;http://rosettacode.org/wiki/List_comprehensions#JavaScript&quot;&gt;list comprehensions&lt;/a&gt;. And there are other languages that compile to JavaScript and can be fairly easily integrated into JavaScript projects, such as &lt;a href=&quot;http://coffeescript.org&quot;&gt;CoffeeScript&lt;/a&gt; -- which itself is Python-like in a number of ways, including &lt;a href=&quot;http://www.emacswiki.org/emacs/IndentingPython#toc1&quot;&gt;semantic indentation&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;You can put together tools such as &lt;a href=&quot;https://www.firebase.com&quot;&gt;Firebase&lt;/a&gt;, &lt;a href=&quot;http://knockoutjs.com&quot;&gt;Knockout&lt;/a&gt; and &lt;a href=&quot;https://github.com/hiroshi/knockoutFire&quot;&gt;KnockoutFire&lt;/a&gt; to cause changes in your database to automatically and near-instantaneously show up on-screen in your SPA with trivially little code through &lt;a href=&quot;http://knockoutjs.com/documentation/binding-syntax.html&quot;&gt;data-binding&lt;/a&gt;. Of course, there are &lt;a href=&quot;http://haineault.com/blog/177/&quot;&gt;ways&lt;/a&gt; of doing that with a framework like Django as well, but data-binding is integral to the way some SPA frameworks operate.&lt;/p&gt;
&lt;p&gt;Lately I&#39;ve been experimenting with &lt;a href=&quot;http://durandaljs.com&quot;&gt;Durandal&lt;/a&gt; as my SPA framework. It incorporates Knockout, and I&#39;m using KnockoutFire to connect it to a Firebase database. Using a framework like Durandal provides organization for your code, and provides facilities like &lt;a href=&quot;http://durandaljs.com/documentation/Using-The-Router/&quot;&gt;routing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So far, I&#39;m very impressed. The main drawback (other than already-noted inherent weaknesses in Javascript itself) is that the documentation and ecosystems of long-existing, high-profile projects like Django are much more evolved. But those things will get better in time, and I&#39;m looking forward to continuing my explorations with Durandal and Firebase.&lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2013-10-07T17:04:38-04:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2012/02/calculating-the-product-of-a-python-list.html">
<title>(Not) calculating the product of a Python list of for comparison purposes</title>
<link>https://www.garyrobinson.net/2012/02/calculating-the-product-of-a-python-list.html</link>
<description>I came across a stackoverflow question about multiplying the numbers in a Python list. Suggestions there included: def product(list): p =1 for i in list: p *= i return p and from operator import mul reduce(mul, list) Adding my own...</description>
<content:encoded>&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;I came across a &lt;a href=&quot;http://stackoverflow.com/questions/2104782/returning-the-product-of-a-list/9114648#9114648&quot;&gt;stackoverflow question&lt;/a&gt; about multiplying the numbers in a Python list. Suggestions there included:&lt;/p&gt;
&lt;pre class=&quot;default prettyprint&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; overflow-x: auto; overflow-y: auto; width: auto; max-height: 600px; background-position: initial initial; background-repeat: initial initial; padding: 5px; border: 0px initial initial;&quot;&gt;&lt;code style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; product&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;):&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;    p &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #800000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;        p &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;*=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; i&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; p&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;and&lt;/p&gt;
&lt;pre class=&quot;default prettyprint&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; overflow-x: auto; overflow-y: auto; width: auto; max-height: 600px; background-position: initial initial; background-repeat: initial initial; padding: 5px; border: 0px initial initial;&quot;&gt;&lt;code style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;from &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;operator &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; mul&lt;br /&gt;reduce&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;mul&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;Adding my own $.02, you can also do:&lt;/p&gt;
&lt;pre class=&quot;default prettyprint&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; overflow-x: auto; overflow-y: auto; width: auto; max-height: 600px; background-position: initial initial; background-repeat: initial initial; padding: 5px; border: 0px initial initial;&quot;&gt;&lt;code style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;span class=&quot;kwd&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #00008b; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; math&lt;br /&gt;math&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;exp&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;math&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; list&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;)))&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;which gets the same numerical results (at least to as way more decimal places than you&#39;re ever likely to care about, the difference being due to computational floating point errors). It&#39;s probably not as readable as the reduce-based solution, though if you&#39;re a mathematician who isn&#39;t familiar with reduce(), the opposite would be true!&lt;/p&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;(The underlying principle is that a * b * c * … * z == e ^ (ln(a) + ln(b) + ln( c) &lt;span style=&quot;font-size: 14px;&quot;&gt;+ … + ln(z)).)&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;I wouldn&#39;t necessarily advise using the log-based solution under normal circumstances. But if you&#39;re ever in a situation where you risk overflow or overflow, such as in&lt;/p&gt;
&lt;pre class=&quot;default prettyprint&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; overflow-x: auto; overflow-y: auto; width: auto; max-height: 600px; background-position: initial initial; background-repeat: initial initial; padding: 5px; border: 0px initial initial;&quot;&gt;&lt;code style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; reduce&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;mul&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #800000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;10.&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;] * &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #800000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;309&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;inf&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;and your purpose is to compare the products of different sequences rather than to know specifically what the products are, then, you can accomplish your purposes without actually computing the entire product. Rather, you can compare the sums of the logs of the terms, without bothering to compute the product by taking the exponential. Whichever list has a larger sum-of-logs also has the larger product. So, following up on our previous example,&lt;/p&gt;
&lt;pre class=&quot;default prettyprint&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; overflow-x: auto; overflow-y: auto; width: auto; max-height: 600px; background-position: initial initial; background-repeat: initial initial; padding: 5px; border: 0px initial initial;&quot;&gt;&lt;code style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt; sum&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;math&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #800000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;10.&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;] * &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #800000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;309&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #800000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;711.49879373515785&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; color: #000000; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;is the way to go because it&#39;s virtually impossible to have a real-world problem in which you would overflow or underflow with this approach. (The larger the result of that calculation is, the larger the product would be if you &lt;em style=&quot;font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; font-style: italic; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;&quot;&gt;could&lt;/em&gt; calculate it.)&lt;/p&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;Accordingly, if you wanted to compare 10. ^ 309 and 11. ^ 309, you could do&lt;/p&gt;
&lt;pre class=&quot;default prettyprint&quot; style=&quot;margin: 0px 0px 10px; font-size: 14px; vertical-align: baseline; background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; overflow: auto; width: auto; max-height: 600px; padding: 5px;&quot;&gt;&lt;code style=&quot;vertical-align: baseline; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; padding: 0px; margin: 0px;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt; sum&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;math&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;vertical-align: baseline; background-color: transparent; color: #800000; padding: 0px; margin: 0px;&quot;&gt;10.&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;] * &lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;vertical-align: baseline; background-color: transparent; color: #800000; padding: 0px; margin: 0px;&quot;&gt;309&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;)) &amp;gt; sum(map(math.log, [11.] * 309))&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;vertical-align: baseline; background-color: transparent; padding: 0px; margin: 0px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;lit&quot; style=&quot;vertical-align: baseline; background-color: transparent; color: #800000; padding: 0px; margin: 0px;&quot;&gt;False&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt;[Originally posted as &quot;Calculating the product of a Python list. Updated for clarity and completeness.]&lt;/p&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt; &lt;/p&gt;
&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; font-size: 14px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; clear: both; word-wrap: break-word; background-position: initial initial; background-repeat: initial initial; padding: 0px; border: 0px initial initial;&quot;&gt; &lt;/p&gt;
&lt;!-- Technorati Tags End --&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2012-02-02T10:48:31-05:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2011/06/seleniums-webdriver-python-dealing-with-script-timeouts.html">
<title>Selenium&#39;s WebDriver &amp; Python: Dealing with script timeouts</title>
<link>https://www.garyrobinson.net/2011/06/seleniums-webdriver-python-dealing-with-script-timeouts.html</link>
<description>Selenium&#39;s WebDriver is a great way to interact with web sites in an automated way. It&#39;s primarily for testing, though I&#39;ve also had occasion to use it for other purposes (with the permission of the relevant site owners). In order...</description>
<content:encoded>&lt;p&gt;Selenium&#39;s WebDriver is a great way to interact with web sites in an automated way. It&#39;s primarily for testing, though I&#39;ve also had occasion to use it for other purposes (with the permission of the relevant site owners).&lt;/p&gt;
&lt;p&gt;In order to interact with sites that use a lot of Javascript, it&#39;s helpful to use Selenium&#39;s Firefox driver. It works great, but I did have one problem, where scripts were timing out. You can modify Firefox&#39;s timeouts via changing preferences, but Selenium&#39;s Firefox driver uses its own profile, so it ignores Firefox&#39;s usual means for changing preferences.&lt;/p&gt;
&lt;p&gt;I searched the web for solutions and found various suggestions that didn&#39;t work. Perhaps many of them worked with pre-WebDriver versions of Selenium, I don&#39;t know.&lt;/p&gt;
&lt;p&gt;In any case, the following worked for me to change the timeouts to 10 minutes:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;from selenium import webdriver&lt;/span&gt;&lt;/pre&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;profile = webdriver.firefox \&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt; .firefox_profile.FirefoxProfile()&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;set_pref = profile.set_preference&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;set_pref(&#39;dom.max_script_run_time&#39;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;600)&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;set_pref(&#39;dom.max_chrome_script_run_time&#39;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;600)&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;;&quot;&gt;driver = webdriver.Firefox(fx_profile=profile)&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Note that the dom.max_chrome_script_run_time preference has nothing to do with Google Chrome, it&#39;s related to Firefox&#39;s internal &lt;/span&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;a href=&quot;http://kb.mozillazine.org/Chrome_URLs&quot;&gt;Chrome URL&#39;s&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;. In fact, for my purposes, I only needed to change dom.max_chrome_script_run_time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Note: if you&#39;re not familiar with WebDriver, do help(webdriver.Firefox) for a description of the methods you have available for interacting with sites. Hint: the oddest thing is that to fill in a text field, you get an object representing the element with the text field, and then call myElement.send_keys(&quot;the text&quot;).&lt;/p&gt;
&lt;p&gt;Update: Docs on the Python bindings may be found &lt;a href=&quot;http://code.google.com/p/selenium/wiki/PythonBindings&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2011-06-01T12:00:56-04:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2009/10/non-blocking-raw_input-for-python.html">
<title>Non-blocking raw_input for Python</title>
<link>https://www.garyrobinson.net/2009/10/non-blocking-raw_input-for-python.html</link>
<description>I needed a way to allow a raw_input() call to time out. In case it&#39;s useful to anyone, I wrote this solution which works under Unix-like OS&#39;s. Simply call nonBlockingRawInput(&quot;your prompt text&quot;, n) where n is the number of seconds...</description>
<content:encoded>&lt;p&gt;I needed a way to allow a raw_input() call to time out. In case it&#39;s useful to anyone, I wrote this solution which works under Unix-like OS&#39;s.&lt;/p&gt;
&lt;p&gt;Simply call nonBlockingRawInput(&quot;your prompt text&quot;, n) where n is the number of seconds you would like the prompt to wait until it times out. If it does time out, it will return with an empty string.&lt;/p&gt;
&lt;pre&gt;import signal

class AlarmException(Exception):
    pass

def alarmHandler(signum, frame):
    raise AlarmException

def nonBlockingRawInput(prompt=&#39;&#39;, timeout=20):
    signal.signal(signal.SIGALRM, alarmHandler)
    signal.alarm(timeout)
    try:
        text = raw_input(prompt)
        signal.alarm(0)
        return text
    except AlarmException:
        print &#39;\nPrompt timeout. Continuing...&#39;
    signal.signal(signal.SIGALRM, signal.SIG_IGN)
    return &#39;&#39;&lt;/pre&gt;
&lt;p&gt;[Edited Aug. 30, 2010 to fix a typo in the function name and generally improve formatting]&lt;/p&gt;
&lt;p&gt;[Edited Feb 1, 2022 to add a tad more explanation, since the comments indicate people are still finding this!]&lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>
<dc:subject>Web/Tech</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2009-10-17T14:19:10-04:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2008/04/splitting-a-pyt.html">
<title>Splitting a Python list into sublists</title>
<link>https://www.garyrobinson.net/2008/04/splitting-a-pyt.html</link>
<description>[Edited Dec 6, 2010 to mention another solution based on zip and iter.] Suppose you want to divide a Python list into sublists of approximately equal size. Since the number of desired sublists may not evenly divide the length of...</description>
<content:encoded>&lt;p&gt;[Edited Dec 6, 2010 to mention another solution based on zip and iter.]&lt;/p&gt;
&lt;p&gt;Suppose you want to divide a Python list into sublists of approximately equal size. Since the number of desired sublists may not evenly divide the length of the original list, this task is (just) a tad more complicated than one might at first assume.&lt;/p&gt;
&lt;p&gt;One &lt;a href=&quot;http://aspn.activestate.com/ASPN/Cookbook/Python&quot;&gt;Python Cookbook&lt;/a&gt; &lt;a href=&quot;http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425397&quot;&gt;entry&lt;/a&gt; is:&lt;/p&gt;
&lt;pre&gt;def slice_it(li, cols=2):
    start = 0
    for i in xrange(cols):
        stop = start + len(li[i::cols])
        yield li[start:stop]
        start = stop&lt;/pre&gt;
&lt;p&gt;which gives the exact number of subsequences, while varying the length of the subsequences a bit if necessary. It uses Python&#39;s slicing feature to get the lengths.&lt;/p&gt;
&lt;p&gt;That was written in response to an &lt;a href=&quot;http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425044&quot;&gt;earlier&lt;/a&gt; cookbook entry which had the following one-liner:&lt;/p&gt;
&lt;pre&gt;[seq[i:i+size] for i  in range(0, len(seq), size)]&lt;/pre&gt;
&lt;p&gt;I like that it&#39;s a one-liner but don&#39;t like a couple of things about it. If your goal isn&#39;t a particular sublist length but rather to divide the list up into pieces, you need another line to compute the size. And then it doesn&#39;t turn out too well. Suppose you want to divide a string of length 10 into 4 substrings:&lt;/p&gt;
&lt;pre&gt;&amp;gt;&amp;gt;&amp;gt; size=10/4
&amp;gt;&amp;gt;&amp;gt; size
2
&amp;gt;&amp;gt;&amp;gt; seq = [1,2,3,4,5,6,7,8,9,10]
&amp;gt;&amp;gt;&amp;gt; [seq[i:i+size] for i  in range(0, len(seq), size)]
[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]&lt;/pre&gt;
&lt;p&gt;This leaves us with one substring more than desired.&lt;/p&gt;
&lt;p&gt;Try setting size to 3 to get fewer substrings:&lt;/p&gt;
&lt;pre&gt;&amp;gt;&amp;gt;&amp;gt; size=3
&amp;gt;&amp;gt;&amp;gt; [seq[i:i+size] for i  in range(0, len(seq), size)]
[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] &lt;/pre&gt;
&lt;p&gt;This leaves us with dissimilar lengths.&lt;/p&gt;
&lt;p&gt;Here&#39;s a briefer one-liner using the slice idea, which doesn&#39;t require you to compute the length in advance, and does give the exact number of subsequences you want and with lengths that are more appropriately divided:&lt;/p&gt;
&lt;pre&gt;[seq[i::num] for i in range(num)]&lt;/pre&gt;
&lt;p&gt;The drawback here is that the subsequences are not actually subsequences of seq; seq is sliced and diced. But, in many situations that doesn&#39;t matter. In any case, all the elements are in the output and the subsequences are as close as possible to the same length:&lt;/p&gt;
&lt;pre&gt;&amp;gt;&amp;gt;&amp;gt; seq = [1,2,3,4,5,6,7,8,9,10]
&amp;gt;&amp;gt;&amp;gt; [seq[i::num] for i in range(num)]
[[1, 5, 9], [2, 6, 10], [3, 7], [4, 8]]&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Update: I just read about a clever and interesting solution involving zip and tier that works in Python 2.7:&lt;/p&gt;
&lt;pre&gt;&amp;gt;&amp;gt;&amp;gt; items, chunk = [1,2,3,4,5,6,7,8,9], 3&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; zip(*[iter(items)]*chunk)&lt;br /&gt;[(1, 2, 3), (4, 5, 6), (7, 8, 9)]&lt;/pre&gt;
&lt;p&gt;Read a full explanation at &lt;a href=&quot;http://paddy3118.blogspot.com&quot;&gt;Go deh!&lt;/a&gt; The disadvantage from a practical point of view is that the if the list of items is not evenly divisible into chunks, some items get left out. But I still like it because it&#39;s illuminating about the nuances of iterators.&lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2008-04-10T15:17:21-04:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2004/07/more_cleaning_u.html">
<title>More cleaning up Python __init__() methods</title>
<link>https://www.garyrobinson.net/2004/07/more_cleaning_u.html</link>
<description>A while ago I posted a suggestion for how to eliminate some mindless code in python __init__() methods when you want to assign instance attributes from __init__() args. Henry Crutcher postedhis own solution on Thursday in the Python Cookbook. I&#39;ve...</description>
<content:encoded>&lt;p&gt;A while ago I posted a suggestion for how to eliminate some mindless code in python __init__() methods when you want to assign instance attributes from __init__() args.&lt;/p&gt;
&lt;p&gt;Henry Crutcher posted&lt;a href=&quot;http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286185&quot;&gt;his own solution&lt;/a&gt; on Thursday in the &lt;a href=&quot;http://aspn.activestate.com/ASPN/Cookbook/Python&quot;&gt;Python Cookbook&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&#39;ve combined the two approaches in a comment to that post (on the same page). I think it&#39;s getting to be a good solution.&lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2004-07-03T07:57:47-04:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2004/04/cleaning_up_pyt.html">
<title>Cleaning up Python __init__() methods</title>
<link>https://www.garyrobinson.net/2004/04/cleaning_up_pyt.html</link>
<description>The ASPN site yesterday presented a technique to eliminate a lot of verbosity in Python __init__() methods where a bunch of arguments to __init__() are assigned to instance attributes. Such assignments are a frequent source of error due to forgetting...</description>
<content:encoded>&lt;p&gt;The ASPN site yesterday presented a technique to eliminate a lot of verbosity in Python __init__() methods where a bunch of arguments to __init__() are assigned to instance attributes. Such assignments are a frequent source of error due to forgetting one or more assignments and/or making spelling errors for the names.&lt;/p&gt;
&lt;p&gt;They presented a function for doing the assignments automatically, but required that the __init__() that uses it has no logic with temporary variables -- an unworkable restriction IMHO.&lt;/p&gt;
&lt;p&gt;So I added a comment with a version that works even when there is other logic with temporary variables. If you&#39;re a Python coder you might want to &lt;a href=&quot;http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/280381&quot;&gt;check it out&lt;/a&gt;.&lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2004-04-28T14:57:29-04:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2004/03/one_line_python.html">
<title>One line Python HTTP server</title>
<link>https://www.garyrobinson.net/2004/03/one_line_python.html</link>
<description>[Most recently updated: Oct 29, 2013.] One of the sweet things that comes with a Python installation is the ability to start up an http server in just one line. Since just about every modern computer (not counting tablets and...</description>
<content:encoded>&lt;p&gt;[Most recently updated: Oct 29, 2013.]&lt;/p&gt;
&lt;p&gt;One of the sweet things that comes with a Python installation is the ability to start up an http server in just one line. Since just about every modern computer (not counting tablets and phones!) has Python, you almost certainly can start up an http server to serve some files in a chosen directory with one quick line of code.&lt;/p&gt;
&lt;p&gt;Go to your terminal. Go to the directory you want to serve HTML files from, then type one of the following, depending on your python version:&lt;/p&gt;
&lt;p&gt;Python 2.x:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;python -m SimpleHTTPServer&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Python 3.x:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;python -m http.server&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Note that the output on your terminal will say:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Serving HTTP on 0.0.0.0 port 8000 ...&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The mention of 0.0.0.0 does not mean the web server is listening at that IP address. Rather, it will be listening at 127.0.0.1:8000. The 0.0.0.0 signifies that the web server will respond to requests that end up on that machine &lt;a href=&quot;http://stackoverflow.com/a/4341808/595094&quot;&gt;no matter the hostname or IP that was requested&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that you can start your web server at port &lt;em&gt;nnnn&lt;/em&gt; with: &lt;/p&gt;
&lt;p&gt;Python 2.x:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;python -m SimpleHTTPServer nnnn&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Python 3.x:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;python -m http.server nnnn&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;div&gt;Of course, starting an http server can be made even more convenient by an alias in your .bashrc (or the equivalent for your OS/shell). A commenter noted that he did so, so I thought I might as well add it to the main post:&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;em&gt;alias http=&quot;python -m SimpleHTTPServer&quot;&lt;/em&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;p&gt;which lets you start a server on port &lt;em&gt;nnnn&lt;/em&gt; for the current directory with:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;http nnnn&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This post has been updated a few times to include improved one-liners pointed out by readers as well as for clarity and completeness. I&#39;ve deleted the original text since it&#39;s quite obsolete now. That might make some of the comments indecipherable because of the lack of context, but it&#39;s all for the greater good. If you have any comments/suggests/observations, please speak up!  &lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>
<dc:subject>Web/Tech</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2004-03-18T08:21:58-05:00</dc:date>
</item>
<item rdf:about="https://www.garyrobinson.net/2004/03/python_singleto.html">
<title>Python Singleton mixin class</title>
<link>https://www.garyrobinson.net/2004/03/python_singleto.html</link>
<description>Here&#39;s a quite complete Singleton mixin class for Python, including such niceties as thread safety for singleton creation. Public domain. Based in part on ideas I found on this wiki page, followed by a substantial number of enhancements based on...</description>
<content:encoded>&lt;p&gt;&lt;a href=&quot;http://www.garyrobinson.net/singletonmixin.py&quot;&gt;Here&#39;s a quite complete Singleton mixin class for Python&lt;/a&gt;, including such niceties as thread safety for singleton creation. Public domain. Based in part on ideas I found on &lt;a href=&quot;http://c2.com/cgi/wiki?PythonSingleton&quot;&gt;this wiki page&lt;/a&gt;, followed by a substantial number of enhancements based on comments posted below and based on my own additional needs. If you find it useful and think of ways to improve it, please post a comment here.&lt;/p&gt;
&lt;p&gt;Lately I&#39;ve noticed some discussion of the evilness of singletons. One &lt;a href=&quot;http://steve.yegge.googlepages.com/singleton-considered-stupid&quot;&gt;poster&lt;/a&gt; says:&lt;/p&gt;
&lt;blockquote&gt;It&#39;s almost impossible to subclass a Singleton, and if you manage it, then you shouldn&#39;t have been using a Singleton in the first place. You don&#39;t *even* want to go there. I&#39;ve walked roads that I dare not recount. Just pretend you can&#39;t do it, and you&#39;ll save yourself amazing amounts of pain.&lt;/blockquote&gt;
&lt;p&gt;My singleton mixin source includes unit tests showing that at least rudimentary subclassing does work with the approach used here. I haven&#39;t run into any problems in real life either, although I use singletons sparingly. &lt;/p&gt;
&lt;p&gt;If anyone has examples or thoughts about problems with subclassing with this mixin, please post a comment.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Update, July 28, 2009: Now optionally allows multiple calls to getInstance() which all include arguments. See the docstring for more. &lt;/em&gt; &lt;em&gt;Update, July 27, 2009: I try to keep the Singleton version here in sync with our svn version, so that any enhancements or fixes will be included. The code, still at the original link (above), has been modified today to add thread safety for singleton creation, and also incorporates ideas from some of the recent comments people have posted here. In particular, singleton construction can now handle keyword arguments. &lt;/em&gt;&lt;/p&gt;</content:encoded>


<dc:subject>Python</dc:subject>

<dc:creator>Gary Robinson</dc:creator>
<dc:date>2004-03-11T15:04:52-05:00</dc:date>
</item>


</rdf:RDF>

<!-- ph=1 -->
