<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-2962</id>
	<title>Nabble - Python - python-list</title>
	<updated>2009-12-24T04:51:57Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/Python---python-list-f2962.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Python---python-list-f2962.html" />
	<subtitle type="html">General discussion list for the Python programming language</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26913613</id>
	<title>Re: Problem with Dynamically unloading a module</title>
	<published>2009-12-24T04:51:57Z</published>
	<updated>2009-12-24T04:51:57Z</updated>
	<author>
		<name>Jean-Michel Pichavant</name>
	</author>
	<content type="html">Steven D'Aprano wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Wed, 23 Dec 2009 15:31:53 +0100, Jean-Michel Pichavant wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Steven D'Aprano wrote:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; But believe me, you don't want to mess up with the python import
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; mechanism.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Unless you understand how it works.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Let me quote the OP: 'Not an expert in Python' I was just answering the
&lt;br&gt;&amp;gt;&amp;gt; OP question, without refering to something he could do if he was someone
&lt;br&gt;&amp;gt;&amp;gt; else.
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; But what he *can* do is to learn how importing works. I'm not sure it's 
&lt;br&gt;&amp;gt; terribly helpful to tell somebody all the things they can't do instead of 
&lt;br&gt;&amp;gt; what they can.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; 
&lt;/div&gt;Hacking python imports would not be in the top of the list of things I 
&lt;br&gt;would teach to some python newcomer, that was my point.
&lt;br&gt;&lt;br&gt;And to be a little more constructive, let's give the OP a litle bit of help.
&lt;br&gt;&lt;br&gt;How can you unload module in python ?
&lt;br&gt;&lt;br&gt;That I don't know, anyone knows ?
&lt;br&gt;&lt;br&gt;JM
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-Dynamically-unloading-a-module-tp26899969p26913613.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26913497</id>
	<title>Re: Regex help needed!</title>
	<published>2009-12-24T04:35:09Z</published>
	<updated>2009-12-24T04:35:09Z</updated>
	<author>
		<name>Anthra Norell-2</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;On 21.12.2009 12:38, Oltmans wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello,. everyone.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I've a string that looks something like
&lt;br&gt;&amp;gt; ----
&lt;br&gt;&amp;gt; lksjdfls&amp;lt;div id ='amazon_345343'&amp;gt; &amp;nbsp;kdjff lsdfs&amp;lt;/div&amp;gt; &amp;nbsp;sdjfls&amp;lt;div id
&lt;br&gt;&amp;gt; = &amp;nbsp; &amp;quot;amazon_35343433&amp;quot;&amp;gt;sdfsd&amp;lt;/div&amp;gt;&amp;lt;div id='amazon_8898'&amp;gt;welcome&amp;lt;/div&amp;gt;
&lt;br&gt;&amp;gt; ----
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; From above string I need the digits within the ID attribute. For
&lt;br&gt;&amp;gt; example, required output from above string is
&lt;br&gt;&amp;gt; - 35343433
&lt;br&gt;&amp;gt; - 345343
&lt;br&gt;&amp;gt; - 8898
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I've written this regex that's kind of working
&lt;br&gt;&amp;gt; re.findall(&amp;quot;\w+\s*\W+amazon_(\d+)&amp;quot;,str)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; but I was just wondering that there might be a better RegEx to do that
&lt;br&gt;&amp;gt; same thing. Can you kindly suggest a better/improved Regex. Thank you
&lt;br&gt;&amp;gt; in advance.
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;
&lt;/div&gt;&lt;br&gt;If you filter in two or even more sequential steps the problem becomes a 
&lt;br&gt;lot simpler, not least because you can
&lt;br&gt;test each step separately:
&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; r1 = re.compile ('&amp;lt;div id\D*\d+[^&amp;gt;]*') &amp;nbsp; # Add ignore case and 
&lt;br&gt;variable white space
&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; r2 = re.compile ('\d+')
&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; [r2.search (item).group () for item in r1.findall (s) if item] &amp;nbsp; &amp;nbsp; 
&lt;br&gt;# s is your sample
&lt;br&gt;['345343', '35343433', '8898'] &amp;nbsp; &amp;nbsp; # Supposing all ids have digits
&lt;br&gt;&lt;br&gt;Frederic
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Regex-help-needed%21-tp26872865p26913497.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26913073</id>
	<title>Re: how to register with pypi - no such setup.py</title>
	<published>2009-12-24T03:32:26Z</published>
	<updated>2009-12-24T03:32:26Z</updated>
	<author>
		<name>&quot;Martin v. Löwis&quot;</name>
	</author>
	<content type="html">&amp;gt; Any tips?
&lt;br&gt;&lt;br&gt;A binary distribution won't have a setup.py, because
&lt;br&gt;you can install it by other means (such as Windows Installer),
&lt;br&gt;instead of running setup.py
&lt;br&gt;&lt;br&gt;What you want is a source distribution (sdist).
&lt;br&gt;&lt;br&gt;Even if you want to create a binary distribution, don't use the
&lt;br&gt;bdist command, but some specialization, such as bdist_rpm.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;Martin
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/how-to-register-with-pypi---no-such-setup.py-tp26890185p26913073.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26912522</id>
	<title>Re: Object Relational Mappers are evil (a meditation)</title>
	<published>2009-12-24T02:54:18Z</published>
	<updated>2009-12-24T02:54:18Z</updated>
	<author>
		<name>Lie Ryan</name>
	</author>
	<content type="html">On 12/24/2009 12:11 PM, Terry Reedy wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; This buggy idiom survived many years of Python development, missed by
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; virtually everyone.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The last statement is false. The hazard of using and/or was well-known
&lt;br&gt;&amp;gt; back in '97 or so when I discovered or learned it and I believe it was
&lt;br&gt;&amp;gt; mentioned in the FAQ entry on the subject. The new alternative has the
&lt;br&gt;&amp;gt; hazard that the condition and if-branch must be written and read in a
&lt;br&gt;&amp;gt; backwards order. I consider that buggy and do not use it for that reason.
&lt;br&gt;&lt;br&gt;Oh really? I thought putting the conditional in the middle was 
&lt;br&gt;ingenious, whoever thought that must have the next Turing award!
&lt;br&gt;&lt;br&gt;I always feel there's something wrong with the (condition ? true : 
&lt;br&gt;false) or (if condition then true else false) expressions found in other 
&lt;br&gt;languages; and just realized it was because of their unnatural ordering. 
&lt;br&gt;I have to admit initially the reversed ordering do confound me, but 
&lt;br&gt;afterward it felt even more natural than the traditional 
&lt;br&gt;&amp;quot;conditional-first&amp;quot; expression.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Object-Relational-Mappers-are-evil-%28a-meditation%29-tp25751882p26912522.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26912377</id>
	<title>Re: wave robot notes</title>
	<published>2009-12-24T02:36:33Z</published>
	<updated>2009-12-24T02:36:33Z</updated>
	<author>
		<name>Duncan Booth-2</name>
	</author>
	<content type="html">Aaron Watters &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26912377&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;aaron.watters@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I implemented a Google Wave Robot which annotates
&lt;br&gt;&amp;gt; BNF syntax rules using railroad diagram images.
&lt;br&gt;&amp;gt; I put notes about the implementation process
&lt;br&gt;&amp;gt; here for the benefit of posterity.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://listtree.appspot.com/firstWaveRobot&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://listtree.appspot.com/firstWaveRobot&lt;/a&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The robot Id is
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26912377&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;whiff-gae-tutorial@...&lt;/a&gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -- if you are using wave, please add it to a wave and try it out.
&lt;br&gt;&amp;gt; It should &amp;quot;respond&amp;quot; to a BNF rule you type in like this one:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; program ::= &amp;quot;begin&amp;quot; (statement &amp;quot;;&amp;quot;)+ &amp;quot;end&amp;quot; $$
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Happy Holidays everyone... I'm off to the slopes :).
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;-- Aaron Watters
&lt;/div&gt;&lt;br&gt;Nice one.
&lt;br&gt;&lt;br&gt;Smooth curves would be nicer than angles if your graphics are up to it.
&lt;br&gt;&lt;br&gt;If you repeat an expression that already exists further up the Wave it 
&lt;br&gt;looks like the robot ignores the duplicate. Is that deliberate?
&lt;br&gt;&lt;br&gt;This one looks nice if you want a reasonably complex example.
&lt;br&gt;&lt;br&gt;import_stmt ::= &amp;quot;import&amp;quot; module [&amp;quot;as&amp;quot; name]( &amp;quot;,&amp;quot; module [&amp;quot;as&amp;quot; name] )*| 
&lt;br&gt;&amp;quot;from&amp;quot; relative_module &amp;quot;import&amp;quot; identifier[&amp;quot;as&amp;quot; name]( &amp;quot;,&amp;quot; identifier 
&lt;br&gt;[&amp;quot;as&amp;quot;name] )*| &amp;quot;from&amp;quot; relative_module &amp;quot;import&amp;quot; &amp;quot;(&amp;quot;identifier [&amp;quot;as&amp;quot; name]( 
&lt;br&gt;&amp;quot;,&amp;quot;identifier [&amp;quot;as&amp;quot; name] )* [&amp;quot;,&amp;quot;] &amp;quot;)&amp;quot;| &amp;quot;from&amp;quot; module &amp;quot;import&amp;quot; &amp;quot;*&amp;quot; &amp;nbsp;
&lt;br&gt;&lt;br&gt;It would be really great if the diagram was interactive: I don't know if 
&lt;br&gt;Wave's api lets you define anchors and jumps to anchors, but if it does 
&lt;br&gt;then you could make non-terminals clickable.
&lt;br&gt;&lt;br&gt;P.S. could you use a standard signature separator please so I don't have to 
&lt;br&gt;trim your signature off the reply by hand?
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/wave-robot-notes-tp26910083p26912377.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26910187</id>
	<title>Re: Problem with Dynamically unloading a module</title>
	<published>2009-12-23T19:20:32Z</published>
	<updated>2009-12-23T19:20:32Z</updated>
	<author>
		<name>Steve Holden-5</name>
	</author>
	<content type="html">lordofcode wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi All
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Not an expert in Python, so sorry if this sounds like a silly
&lt;br&gt;&amp;gt; question.
&lt;br&gt;&amp;gt; I went through other few threads in the mailing list but they are not
&lt;br&gt;&amp;gt; helping me much.
&lt;br&gt;&amp;gt; I have run into a problem related to dynamically loading and unloading
&lt;br&gt;&amp;gt; a module.
&lt;br&gt;&amp;gt; I need to dynamically load a module and unload it and load another
&lt;br&gt;&amp;gt; module.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; For example I have many files(All files in Python are modules right?)
&lt;br&gt;&amp;gt; like mobile_1.py ,mobile_2.py, mobile_3.py &amp;nbsp;etc.. in my project folder
&lt;br&gt;&amp;gt; which contains classes and methods with same name but different
&lt;br&gt;&amp;gt; functionality.(am afraid I cannot change this structure as these files
&lt;br&gt;&amp;gt; are generated randomly by the user)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; So initially when my program starts I have to load a default module. I
&lt;br&gt;&amp;gt; do this as follows:
&lt;br&gt;&amp;gt; ##############################
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; MODULE_name = &amp;quot;mobile_1&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; exec &amp;quot;from &amp;quot;+MODULE_name+&amp;quot; import *&amp;quot;
&lt;br&gt;&amp;gt; ##############################
&lt;br&gt;&amp;gt; And use the methods defined in &amp;quot;mobile_1.py&amp;quot; file
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Now as the application continues , I may have to use the methods
&lt;br&gt;&amp;gt; defined in &amp;quot;mobile_2.py&amp;quot; or &amp;quot;mobile_3.py&amp;quot; etc instead of the
&lt;br&gt;&amp;gt; previously loaded module,which I incorrectly try to do as below:
&lt;br&gt;&amp;gt; ####################
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; MODULE_name = &amp;quot;mobile_2&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; exec &amp;quot;from &amp;quot;+MODULE_name+&amp;quot; import *&amp;quot;
&lt;br&gt;&amp;gt; #####################
&lt;br&gt;&amp;gt; The above import does not have any impact and the methods called from
&lt;br&gt;&amp;gt; my application still pertain to mobile_1.py as its still in the
&lt;br&gt;&amp;gt; current namespace(?).
&lt;br&gt;&amp;gt; I tried below code with del(), reload() etc but could not figure it
&lt;br&gt;&amp;gt; out.
&lt;br&gt;&amp;gt; ###Code to unload a dll####
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; del sys.modules[MODULE_name] &amp;nbsp; &amp;nbsp;#==&amp;gt; does not delete the reference in namespace
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 1)How do I unload a module dynamically and completely remove the
&lt;br&gt;&amp;gt; references in the module so a new module with same name references can
&lt;br&gt;&amp;gt; be loaded?
&lt;br&gt;&amp;gt; 2)Are there any alternative way to do the above requirement?
&lt;br&gt;&amp;gt; Currently I am working around by restarting the whole initial setup
&lt;br&gt;&amp;gt; for each new module which is unnecessary waste.Can I avoid this
&lt;br&gt;&amp;gt; &amp;quot;reset&amp;quot;?
&lt;br&gt;&amp;gt; 
&lt;/div&gt;I'd argue that you don't want to unload the old code before loading the
&lt;br&gt;new module, and that what you really need is an understanding that if
&lt;br&gt;mod1 and mod2 both define a function called f then you can perfectly
&lt;br&gt;happily reference the two functions as
&lt;br&gt;&lt;br&gt;&amp;nbsp; mod1.f
&lt;br&gt;&lt;br&gt;and
&lt;br&gt;&lt;br&gt;&amp;nbsp; mod2.f
&lt;br&gt;&lt;br&gt;Indeed, if x is some object that needs processing by functions f, g and
&lt;br&gt;h from module mod1 then it's perfectly valid to write
&lt;br&gt;&lt;br&gt;&amp;nbsp; mod = mod1
&lt;br&gt;&amp;nbsp; result = mod.f(mod.g(mod.h(x)))
&lt;br&gt;&lt;br&gt;for example. So you can write code that uses the appropriate module for
&lt;br&gt;each input.
&lt;br&gt;&lt;br&gt;It's possible, of course, that I am misunderstanding your requirements,
&lt;br&gt;but I hope that helps.
&lt;br&gt;&lt;br&gt;regards
&lt;br&gt;&amp;nbsp;Steve
&lt;br&gt;-- 
&lt;br&gt;Steve Holden &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; +1 571 484 6266 &amp;nbsp; +1 800 494 3119
&lt;br&gt;PyCon is coming! Atlanta, Feb 2010 &amp;nbsp;&lt;a href=&quot;http://us.pycon.org/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://us.pycon.org/&lt;/a&gt;&lt;br&gt;Holden Web LLC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://www.holdenweb.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.holdenweb.com/&lt;/a&gt;&lt;br&gt;UPCOMING EVENTS: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href=&quot;http://holdenweb.eventbrite.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://holdenweb.eventbrite.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-Dynamically-unloading-a-module-tp26899969p26910187.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26910155</id>
	<title>Re: Threading with queues</title>
	<published>2009-12-23T19:11:27Z</published>
	<updated>2009-12-23T19:11:27Z</updated>
	<author>
		<name>Gib Bogle-3</name>
	</author>
	<content type="html">Lie Ryan wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On 12/22/2009 10:47 AM, Gib Bogle wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; This is indented over one indentation level too much. You want it to
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; be at the same level as the for above. Here, its at the same level
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; with &amp;quot;t&amp;quot; -- meaning this entire loop gets repeated five times.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I sorta really recommend a tab width of 4 spaces, not 2 :) At 2, its
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; _really_ hard (especially if you're newer to Python) to see these
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; kinds of issues and since indentation is program logic and structure
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; in Python, that's bad... especially since your comment is indented to
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; the right level, but the code isn't :)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; --S
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; It turns out that this code isn't a great demo of the advantages of
&lt;br&gt;&amp;gt;&amp;gt; threading, on my system anyway. The time taken to execute doesn't vary
&lt;br&gt;&amp;gt;&amp;gt; much when the number of threads is set anywhere from 1 to 6.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; it does in mine:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Elapsed Time: 7.47399997711 (with one thread)
&lt;br&gt;&amp;gt; Elapsed Time: 1.90199995041 (with five threads)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; what sort of weird machine are you in?
&lt;/div&gt;&lt;br&gt;Hmmm, interesting. &amp;nbsp;I am running Windows XP on Intel quad core hardware, Q6600. 
&lt;br&gt;&amp;nbsp; And you?
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Threading-with-queues-tp26881638p26910155.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26910106</id>
	<title>Re: Object Relational Mappers are evil (a meditation)</title>
	<published>2009-12-23T19:02:57Z</published>
	<updated>2009-12-23T19:02:57Z</updated>
	<author>
		<name>Steven D'Aprano-7</name>
	</author>
	<content type="html">On Wed, 23 Dec 2009 20:11:25 -0500, Terry Reedy wrote:
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Instead the accepted, idiomatic Python way of writing this was to use
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; short-circuit booleans:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; result = condition and x or y
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; However this idiom is buggy! If x is a false-value (say, 0) then
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; result gets set to y no matter what the value of condition.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; This is only a bug if one expects otherwise.
&lt;br&gt;&lt;br&gt;I'm not saying the behaviour of `a and x or y` is buggy, but that it's 
&lt;br&gt;use as a replacement for a ternary conditional expression is buggy; the 
&lt;br&gt;*idiom* is buggy, not the behaviour of and/or.
&lt;br&gt;&lt;br&gt;If I say &amp;quot;you can make perfect hard boiled eggs by putting the egg in a 
&lt;br&gt;glass of water in the microwave on high for eight minutes&amp;quot;, and the egg 
&lt;br&gt;explodes, that's not a bug in the microwave, that's a bug in the recipe.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; This buggy idiom survived many years of Python development, missed by
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; virtually everyone.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The last statement is false. The hazard of using and/or was well-known
&lt;br&gt;&amp;gt; back in '97 or so when I discovered or learned it and I believe it was
&lt;br&gt;&amp;gt; mentioned in the FAQ entry on the subject. 
&lt;br&gt;&lt;br&gt;We can argue about how well-known it was for somebody like Raymond 
&lt;br&gt;Hettinger to miss it, and for whoever did a code-review of his 
&lt;br&gt;application to also miss it.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt; The new alternative has the
&lt;br&gt;&amp;gt; hazard that the condition and if-branch must be written and read in a
&lt;br&gt;&amp;gt; backwards order.
&lt;br&gt;&lt;br&gt;If you had asked me a couple of years ago, I would have agreed, but I've 
&lt;br&gt;now come to the conclusion that `x if condition else y` is not only 
&lt;br&gt;perfectly natural, but at least as natural as the conventional order of 
&lt;br&gt;`if condition then x else y` (at least for expressions, not for if 
&lt;br&gt;statements).
&lt;br&gt;&lt;br&gt;&amp;quot;Steven, what are you doing on Monday night?&amp;quot;
&lt;br&gt;&amp;quot;Going to the movies if I can get away from work on time, otherwise 
&lt;br&gt;sitting at home answering questions on comp.lang.python.&amp;quot;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Steven
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Object-Relational-Mappers-are-evil-%28a-meditation%29-tp25751882p26910106.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26910083</id>
	<title>wave robot notes</title>
	<published>2009-12-23T18:59:43Z</published>
	<updated>2009-12-23T18:59:43Z</updated>
	<author>
		<name>Aaron Watters</name>
	</author>
	<content type="html">I implemented a Google Wave Robot which annotates
&lt;br&gt;BNF syntax rules using railroad diagram images.
&lt;br&gt;I put notes about the implementation process
&lt;br&gt;here for the benefit of posterity.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://listtree.appspot.com/firstWaveRobot&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://listtree.appspot.com/firstWaveRobot&lt;/a&gt;&lt;br&gt;&lt;br&gt;The robot Id is
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26910083&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;whiff-gae-tutorial@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;-- if you are using wave, please add it to a wave and try it out.
&lt;br&gt;It should &amp;quot;respond&amp;quot; to a BNF rule you type in like this one:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; program ::= &amp;quot;begin&amp;quot; (statement &amp;quot;;&amp;quot;)+ &amp;quot;end&amp;quot; $$
&lt;br&gt;&lt;br&gt;Happy Holidays everyone... I'm off to the slopes :).
&lt;br&gt;&amp;nbsp; &amp;nbsp;-- Aaron Watters
&lt;br&gt;&lt;br&gt;===
&lt;br&gt;an apple every 8 hours
&lt;br&gt;will keep 3 doctors away --kliban
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/wave-robot-notes-tp26910083p26910083.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26910056</id>
	<title>Re: Problem with Dynamically unloading a module</title>
	<published>2009-12-23T18:50:26Z</published>
	<updated>2009-12-23T18:50:26Z</updated>
	<author>
		<name>Steven D'Aprano-7</name>
	</author>
	<content type="html">On Wed, 23 Dec 2009 15:18:10 -0800, Carl Banks wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; # will unload mod1 assuming mod1 was the only reference to that
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; module.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Which is highly unlikely. Any classes or functions from the module will
&lt;br&gt;&amp;gt;&amp;gt; keep the module alive.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Actually, they won't. &amp;nbsp;Neither classes nor functions directly reference
&lt;br&gt;&amp;gt; their module; classes know their module only by name, and functions only
&lt;br&gt;&amp;gt; hold references to the module's namespace, not to the module itself. &amp;nbsp;So
&lt;br&gt;&amp;gt; if any references to functions defined in the module remain, the module
&lt;br&gt;&amp;gt; dict will stick around, but the module itself may be collected.
&lt;/div&gt;&lt;br&gt;Hmmm... so it seems. Well spotted, thanks.
&lt;br&gt;&lt;br&gt;It makes sense to do it that way, as it prevents circular references 
&lt;br&gt;(module contains a class which contains the module which...).
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Steven
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-Dynamically-unloading-a-module-tp26899969p26910056.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26909943</id>
	<title>Re: Problem with Dynamically unloading a module</title>
	<published>2009-12-23T18:32:15Z</published>
	<updated>2009-12-23T18:32:15Z</updated>
	<author>
		<name>lordofcode</name>
	</author>
	<content type="html">Hi All,
&lt;br&gt;&lt;br&gt;Thanks you all for your replies ,cleared quiet a few doubts about
&lt;br&gt;importing modules and namespace references .
&lt;br&gt;Currently am going with static importing of all modules. But it may
&lt;br&gt;not be efficient in future as the number of interchangeable modules
&lt;br&gt;that I have to import may run in 30-40's.(Basically this Python code
&lt;br&gt;is part of larger GSM Testing project where each module represents one
&lt;br&gt;model of GSM mobile phone and this number keeps growing). So changing
&lt;br&gt;the design will be a last resort.
&lt;br&gt;But am trying to reduce the number of objects(classes,methods etc) in
&lt;br&gt;each module so importing all 30-40 modules do not impact much.
&lt;br&gt;&lt;br&gt;Anyway am trying out all the mentioned tricks here and get back to you
&lt;br&gt;with any doubts.
&lt;br&gt;&lt;br&gt;Thanks again
&lt;br&gt;Ajay Baragur
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-Dynamically-unloading-a-module-tp26899969p26909943.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26909503</id>
	<title>Re: Object Relational Mappers are evil (a meditation)</title>
	<published>2009-12-23T17:11:25Z</published>
	<updated>2009-12-23T17:11:25Z</updated>
	<author>
		<name>Terry Reedy</name>
	</author>
	<content type="html">&lt;br&gt;&amp;gt;&amp;gt; Instead the accepted, idiomatic Python way of writing this was to use
&lt;br&gt;&amp;gt;&amp;gt; short-circuit booleans:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; result = condition and x or y
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; However this idiom is buggy! If x is a false-value (say, 0) then result
&lt;br&gt;&amp;gt;&amp;gt; gets set to y no matter what the value of condition.
&lt;br&gt;&lt;br&gt;This is only a bug if one expects otherwise.
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; This buggy idiom survived many years of Python development, missed by
&lt;br&gt;&amp;gt;&amp;gt; virtually everyone.
&lt;br&gt;&lt;br&gt;The last statement is false. The hazard of using and/or was well-known 
&lt;br&gt;back in '97 or so when I discovered or learned it and I believe it was 
&lt;br&gt;mentioned in the FAQ entry on the subject. The new alternative has the 
&lt;br&gt;hazard that the condition and if-branch must be written and read in a 
&lt;br&gt;backwards order. I consider that buggy and do not use it for that reason.
&lt;br&gt;&lt;br&gt;Terry Jan Reedy
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Object-Relational-Mappers-are-evil-%28a-meditation%29-tp25751882p26909503.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26909141</id>
	<title>Re: creating ZIP files on the cheap</title>
	<published>2009-12-23T16:21:18Z</published>
	<updated>2009-12-23T16:21:18Z</updated>
	<author>
		<name>Emile van Sebille</name>
	</author>
	<content type="html">On 12/23/2009 3:47 PM John Machin said...
&lt;br&gt;&amp;gt;Is it
&lt;br&gt;&amp;gt; maintainable? I.e. pretend that the next person to maintain your code
&lt;br&gt;&amp;gt; knows where you live and owns a chainsaw.
&lt;br&gt;&lt;br&gt;Oooh... that's much better than the finger guillotine and annual 
&lt;br&gt;holiday-party finger count I normally threaten with...
&lt;br&gt;&lt;br&gt;Emile
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/creating-ZIP-files-on-the-cheap-tp26907087p26909141.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908952</id>
	<title>Re: creating ZIP files on the cheap</title>
	<published>2009-12-23T15:47:47Z</published>
	<updated>2009-12-23T15:47:47Z</updated>
	<author>
		<name>John Machin</name>
	</author>
	<content type="html">On Dec 24, 7:34 am, samwyse &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26908952&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;samw...@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; I've got an app that's creating Open Office docs; if you don't know,
&lt;br&gt;&amp;gt; these are actually ZIP files with a different extension.  In my case,
&lt;br&gt;&amp;gt; like many other people, I generating from boilerplate, so only one
&lt;br&gt;&amp;gt; component (content.xml) of my ZIP file will ever change.  Instead of
&lt;br&gt;&amp;gt; creating the entire ZIP file each time, what is the cheapest way to
&lt;br&gt;&amp;gt; accomplish my goal?  I'd kind-of like to just write the first part of
&lt;br&gt;&amp;gt; the file as a binary blob, then write my bit, then write most of the
&lt;br&gt;&amp;gt; table of contents as another blob, and finally write a TOC entry for
&lt;br&gt;&amp;gt; my bit.  Has anyone ever done anything like this?  Thanks.
&lt;br&gt;&lt;br&gt;Option 1: set up a file that contains everything except the
&lt;br&gt;content.xml. Then for each new file: copy the &amp;quot;empty&amp;quot; file, open the
&lt;br&gt;copy with zipfile (mode 'a') and write your content.xml. This at least
&lt;br&gt;is understandable and maintainable.
&lt;br&gt;&lt;br&gt;Option 2 (recommended): insert some timing apparatus into your script.
&lt;br&gt;How much time is taken by the template stuff? Is it worth chancing
&lt;br&gt;your arm on getting the &amp;quot;binary blob&amp;quot; stuff correct? Is it
&lt;br&gt;maintainable? I.e. pretend that the next person to maintain your code
&lt;br&gt;knows where you live and owns a chainsaw.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/creating-ZIP-files-on-the-cheap-tp26907087p26908952.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908829</id>
	<title>RE: Ironpython experience</title>
	<published>2009-12-23T15:28:43Z</published>
	<updated>2009-12-23T15:28:43Z</updated>
	<author>
		<name>Dino Viehland</name>
	</author>
	<content type="html">Lev wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I'm an on and off Python developer and use it as one of the tools.
&lt;br&gt;&amp;gt; Never for writing &amp;quot;full-blown&amp;quot; applications, but rather small, &amp;quot;one-of-
&lt;br&gt;&amp;gt; a-kind&amp;quot; utilities. This time I needed some sort of backup and
&lt;br&gt;&amp;gt; reporting utility, which is to be used by the members of our team
&lt;br&gt;&amp;gt; once or twice a day. Execution time is supposed be negligible. The
&lt;br&gt;&amp;gt; project was an ideal candidate to be implemented in Python. &amp;nbsp;As
&lt;br&gt;&amp;gt; expected the whole script was about 200 lines and was ready in a 2
&lt;br&gt;&amp;gt; hours (the power of Python!).Then I downloaded Ironpython and
&lt;br&gt;&amp;gt; relatively painlessly (except the absence of zlib) converted the
&lt;br&gt;&amp;gt; Python code to Ironpython. Works fine and Ironython really is Python.
&lt;br&gt;&amp;gt; But...
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The CPython 2.6 script runs 0.1 seconds, while Ironpython 2.6 runs
&lt;br&gt;&amp;gt; about 10 seconds. The difference comes from the start-up, when all
&lt;br&gt;&amp;gt; these numerous dlls/assemblies are loaded and JITed.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Is there any way to speed up the process.
&lt;/div&gt;&lt;br&gt;Can you give us more information about the environment you're running
&lt;br&gt;in? &amp;nbsp;E.g. how did you install IronPython, is this on 32-bit or 64-bit
&lt;br&gt;and are you using ipy.exe or ipy64.exe?
&lt;br&gt;&lt;br&gt;The sweet spot to be in is on a 32-bit machine or a 64-bit machine
&lt;br&gt;and using ipy.exe. &amp;nbsp;You should also be using ngen'd (pre-compiled)
&lt;br&gt;binaries which the MSI does for you. &amp;nbsp;Combining 32-bit plus ngen
&lt;br&gt;should greatly reduce startup time and typically on our test machines
&lt;br&gt;it only takes a couple of seconds (&lt;a href=&quot;http://ironpython.codeplex.com/wikipage?title=IP26FinalVsCPy26Perf&amp;referringTitle=IronPython%20Performance&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://ironpython.codeplex.com/wikipage?title=IP26FinalVsCPy26Perf&amp;referringTitle=IronPython%20Performance&lt;/a&gt;).
&lt;br&gt;&lt;br&gt;That's still a lot worse than CPython startup time but it's much
&lt;br&gt;better than 10 seconds. &amp;nbsp;We also continue to work on startup time -
&lt;br&gt;there's already some big improvements in our Main branch which should
&lt;br&gt;be showing up in 2.6.1. &amp;nbsp;Matching CPython is still a long ways off
&lt;br&gt;if we ever can do it but do intend to keep on pushing on it.
&lt;br&gt;&amp;nbsp;
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ironpython-experience-tp26899414p26908829.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908715</id>
	<title>Re: Problem with Dynamically unloading a module</title>
	<published>2009-12-23T15:18:10Z</published>
	<updated>2009-12-23T15:18:10Z</updated>
	<author>
		<name>Carl Banks-2</name>
	</author>
	<content type="html">On Dec 23, 7:40 am, Steven D'Aprano &amp;lt;st...@REMOVE-THIS-
&lt;br&gt;cybersource.com.au&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote:
&lt;br&gt;&amp;gt; &amp;gt; 3/ if you really need to unload the previous module, it's a little bit
&lt;br&gt;&amp;gt; &amp;gt; tedious.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; import mod1
&lt;br&gt;&amp;gt; &amp;gt; del mod1
&lt;br&gt;&amp;gt; &amp;gt; sys.modules['mod1'] = None
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Assigning sys.modules[name] to None is not the same as deleting the
&lt;br&gt;&amp;gt; entry. None has special meaning to imports from packages, and for modules
&lt;br&gt;&amp;gt; it is interpreted as meaning that the module doesn't exist.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; import math
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; del math
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; sys.modules['math'] = None
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; import math
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Traceback (most recent call last):
&lt;br&gt;&amp;gt;   File &amp;quot;&amp;lt;stdin&amp;gt;&amp;quot;, line 1, in &amp;lt;module&amp;gt;
&lt;br&gt;&amp;gt; ImportError: No module named math
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; # will unload mod1 assuming mod1 was the only
&lt;br&gt;&amp;gt; &amp;gt; reference to that module.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Which is highly unlikely. Any classes or functions from the module will
&lt;br&gt;&amp;gt; keep the module alive.
&lt;/div&gt;&lt;br&gt;Actually, they won't. &amp;nbsp;Neither classes nor functions directly
&lt;br&gt;reference their module; classes know their module only by name, and
&lt;br&gt;functions only hold references to the module's namespace, not to the
&lt;br&gt;module itself. &amp;nbsp;So if any references to functions defined in the
&lt;br&gt;module remain, the module dict will stick around, but the module
&lt;br&gt;itself may be collected.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt; &amp;gt; But believe me, you don't want to mess up with the python import
&lt;br&gt;&amp;gt; &amp;gt; mechanism.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Unless you understand how it works.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Carl Banks
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-Dynamically-unloading-a-module-tp26899969p26908715.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908275</id>
	<title>Re: python 2.x and running shell command</title>
	<published>2009-12-23T14:22:59Z</published>
	<updated>2009-12-23T14:22:59Z</updated>
	<author>
		<name>half.italian</name>
	</author>
	<content type="html">On Dec 23, 1:57 pm, tekion &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26908275&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;tek...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; All,
&lt;br&gt;&amp;gt; some of the servers I have run python 2.2, which is a drag because I
&lt;br&gt;&amp;gt; can't use subprocess module.  My options that I know of is popen2
&lt;br&gt;&amp;gt; module.  However, it seems it does not have io blocking
&lt;br&gt;&amp;gt; capabilities.   So every time run a command I have open and close a
&lt;br&gt;&amp;gt; file handle.  I have command that requires interactive interaction. I
&lt;br&gt;&amp;gt; want to be be able to perform following action:
&lt;br&gt;&amp;gt; fout, fin = popen2.open2(cmd) #open up interactive session
&lt;br&gt;&amp;gt; fin.write(cmd2);
&lt;br&gt;&amp;gt; block (input)
&lt;br&gt;&amp;gt; fout.readline()
&lt;br&gt;&amp;gt; block output
&lt;br&gt;&amp;gt; fin.write(cmd2)
&lt;br&gt;&amp;gt; and so on...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; is this possible with popen2 or do I have to use pexpect for the job?
&lt;br&gt;&amp;gt; Thanks.
&lt;/div&gt;&lt;br&gt;I've never done that with subprocess, but maybe this will help:
&lt;br&gt;&lt;a href=&quot;http://www.lysator.liu.se/~astrand/popen5/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.lysator.liu.se/~astrand/popen5/&lt;/a&gt;&lt;br&gt;&lt;br&gt;~Sean
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/python-2.x-and-running-shell-command-tp26908018p26908275.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908088</id>
	<title>Re: Problem with Dynamically unloading a module</title>
	<published>2009-12-23T14:04:53Z</published>
	<updated>2009-12-23T14:04:53Z</updated>
	<author>
		<name>Steven D'Aprano-7</name>
	</author>
	<content type="html">On Wed, 23 Dec 2009 15:31:53 +0100, Jean-Michel Pichavant wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Steven D'Aprano wrote:
&lt;br&gt;&amp;gt;&amp;gt; On Wed, 23 Dec 2009 13:37:06 +0100, Jean-Michel Pichavant wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; But believe me, you don't want to mess up with the python import
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; mechanism.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt; Unless you understand how it works.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; Let me quote the OP: 'Not an expert in Python' I was just answering the
&lt;br&gt;&amp;gt; OP question, without refering to something he could do if he was someone
&lt;br&gt;&amp;gt; else.
&lt;/div&gt;&lt;br&gt;But what he *can* do is to learn how importing works. I'm not sure it's 
&lt;br&gt;terribly helpful to tell somebody all the things they can't do instead of 
&lt;br&gt;what they can.
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Steven
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Problem-with-Dynamically-unloading-a-module-tp26899969p26908088.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908063</id>
	<title>Re: Object Relational Mappers are evil (a meditation)</title>
	<published>2009-12-23T14:04:38Z</published>
	<updated>2009-12-23T14:04:38Z</updated>
	<author>
		<name>Steven D'Aprano-7</name>
	</author>
	<content type="html">On Wed, 23 Dec 2009 10:55:19 -0500, J Kenneth King wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Steven D'Aprano &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26908063&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;steve@...&lt;/a&gt;&amp;gt; writes:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; On Mon, 21 Dec 2009 11:44:29 -0500, J Kenneth King wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; A programmer that
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; lacks critical thinking is a bad programmer. &amp;nbsp;The language they use
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; has no bearing on such human facilities.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; That's nonsense, and I can demonstrate it by reference to a single
&lt;br&gt;&amp;gt;&amp;gt; programming language, namely Python.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; For many years, Python had no ternary if operator:
&lt;/div&gt;&lt;br&gt;[...]
&lt;br&gt;&lt;br&gt;&amp;gt; But did the lack of ternary encourage Raymond to become a bad
&lt;br&gt;&amp;gt; programmer?
&lt;br&gt;&lt;br&gt;No, but Raymond started off in a position of being an excellent 
&lt;br&gt;programmer. A single buggy idiom lead him to be slightly-less excellent 
&lt;br&gt;than he otherwise would have been. How many buggy idioms would it take to 
&lt;br&gt;lead him to become a mediocre coder, if he was unable to change languages?
&lt;br&gt;&lt;br&gt;Because Python is generally an excellent language, the harm done by one 
&lt;br&gt;or two misfeatures is minor. But less excellent languages encourage 
&lt;br&gt;coding styles, techniques and idioms that encourage the programmer to 
&lt;br&gt;write poor code: either complicated, baroque, unreadable code; or slow 
&lt;br&gt;inefficient code; or buggy code. To avoid starting a flame war, I will 
&lt;br&gt;avoid mentioning PHP. *cough*
&lt;br&gt;&lt;br&gt;Sometimes you know what you need to do to write non-buggy code, but 
&lt;br&gt;because covering all the corners are just Too Damn Hard in a certain 
&lt;br&gt;language, you simply lower your expectations. Error checking is tedious 
&lt;br&gt;and hard to get right in some languages, like C and Pascal, and hence 
&lt;br&gt;even good programmers can miss some errors.
&lt;br&gt;&lt;br&gt;Different languages encourage different mind-sets in the programmer: C 
&lt;br&gt;encourages the coder to think at the low level of pointers and addresses, 
&lt;br&gt;and primarily about machine efficiency; Java encourages the use of big 
&lt;br&gt;object hierarchies and design patterns (it's hard to write lightweight 
&lt;br&gt;code in Java, so everything turns into heavyweight code); Perl encourages 
&lt;br&gt;cleverness and code-golf (writing a program in as few lines or characters 
&lt;br&gt;as possible); Haskell and Lisp encourage a heavily abstract approach that 
&lt;br&gt;often requires an elite coder to follow; Forth encourages you to think 
&lt;br&gt;like Yoda.
&lt;br&gt;&lt;br&gt;&lt;br&gt;[...]
&lt;br&gt;&amp;gt; Good tools make all the difference in the world, I'm not arguing that.
&lt;br&gt;&lt;br&gt;You appear to be arguing against that.
&lt;br&gt;&lt;br&gt;&amp;gt; Just that the tools don't use us; we use them.
&lt;br&gt;&lt;br&gt;Nobody said that tools use us.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt; Programming in Python
&lt;br&gt;&amp;gt; doesn't instantly make me a better programmer.
&lt;br&gt;&lt;br&gt;No, not instantly, but I would argue that after many years of coding in 
&lt;br&gt;Python you will be a better programmer than after the same number of 
&lt;br&gt;years of coding in PHP or Basic.
&lt;br&gt;&lt;br&gt;It also depends on what you mean by &amp;quot;better programmer&amp;quot;. Some languages 
&lt;br&gt;value cleverness above all else. Python is not a language for writing 
&lt;br&gt;amazing, awe-inspiring hacks that work where nobody but the author can 
&lt;br&gt;work out why. This is why there is an Obfuscated C contest and an 
&lt;br&gt;Obfuscated Perl contest but no Obfuscated Python contest -- it wouldn't 
&lt;br&gt;be anywhere near as awe-inspiring.
&lt;br&gt;&lt;br&gt;So one might argue that the best C and Perl coders are better than the 
&lt;br&gt;best Python coders, but the average Python coder is better than the 
&lt;br&gt;average C and Perl coder. 
&lt;br&gt;&lt;br&gt;(I suggest this as a hypothetical, and do not wish to defend it 
&lt;br&gt;scientifically.)
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Steven
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Object-Relational-Mappers-are-evil-%28a-meditation%29-tp25751882p26908063.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908018</id>
	<title>python 2.x and running shell command</title>
	<published>2009-12-23T13:57:28Z</published>
	<updated>2009-12-23T13:57:28Z</updated>
	<author>
		<name>tekion</name>
	</author>
	<content type="html">All,
&lt;br&gt;some of the servers I have run python 2.2, which is a drag because I
&lt;br&gt;can't use subprocess module. &amp;nbsp;My options that I know of is popen2
&lt;br&gt;module. &amp;nbsp;However, it seems it does not have io blocking
&lt;br&gt;capabilities. &amp;nbsp; So every time run a command I have open and close a
&lt;br&gt;file handle. &amp;nbsp;I have command that requires interactive interaction. I
&lt;br&gt;want to be be able to perform following action:
&lt;br&gt;fout, fin = popen2.open2(cmd) #open up interactive session
&lt;br&gt;fin.write(cmd2);
&lt;br&gt;block (input)
&lt;br&gt;fout.readline()
&lt;br&gt;block output
&lt;br&gt;fin.write(cmd2)
&lt;br&gt;and so on...
&lt;br&gt;&lt;br&gt;is this possible with popen2 or do I have to use pexpect for the job?
&lt;br&gt;Thanks.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/python-2.x-and-running-shell-command-tp26908018p26908018.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907868</id>
	<title>Re: More On the Strange Problem</title>
	<published>2009-12-23T13:40:21Z</published>
	<updated>2009-12-23T13:40:21Z</updated>
	<author>
		<name>Steven D'Aprano-7</name>
	</author>
	<content type="html">On Wed, 23 Dec 2009 19:03:36 +0000, MRAB wrote:
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; if whatDo == 'insert':
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; theVal = defaultVal
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; val = defaultVal
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; What's the difference between theVal and val? The names don't help me!
&lt;br&gt;&lt;br&gt;Oh MRAB! Isn't it obvious? theVal has a leading definite article while 
&lt;br&gt;val doesn't!
&lt;br&gt;&lt;br&gt;Really MRAB, if you can't comprehend such clear and obvious code, you'll 
&lt;br&gt;never be a good programmer!
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Steven
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/More-On-the-Strange-Problem-tp26905598p26907868.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907824</id>
	<title>Re: ISO all functions+methods+classes without docstring</title>
	<published>2009-12-23T13:39:27Z</published>
	<updated>2009-12-23T13:39:27Z</updated>
	<author>
		<name>Steven D'Aprano-7</name>
	</author>
	<content type="html">On Wed, 23 Dec 2009 21:08:02 +0000, kj wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; I'm looking for a good way to get a listing of all the undocumented
&lt;br&gt;&amp;gt; (i.e. docstring-less) functions, classes, and methods as defined in a
&lt;br&gt;&amp;gt; (largish) library of files.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; What's a good way to get this information?
&lt;br&gt;&lt;br&gt;&lt;br&gt;list_of_modules = []
&lt;br&gt;for module_name in list_of_files:
&lt;br&gt;&amp;nbsp; &amp;nbsp; list_of_modules.append( __import__(module_name) )
&lt;br&gt;&lt;br&gt;for module in list_of_modules:
&lt;br&gt;&amp;nbsp; &amp;nbsp; for name in dir(module):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; obj = getattr(module, name)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; doc = getattr(obj, '__doc__', None)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if doc is None:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print module, name
&lt;br&gt;&lt;br&gt;&lt;br&gt;The only complication is that dir deliberately only shows &amp;quot;interesting&amp;quot; 
&lt;br&gt;attributes, however that is defined. If this doesn't do what what you 
&lt;br&gt;want, you may prefer to write your own function. The inspect module will 
&lt;br&gt;probably come in handy.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Steven
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/ISO-all-functions%2Bmethods%2Bclasses-without-docstring-tp26907488p26907824.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907586</id>
	<title>Re: creating ZIP files on the cheap</title>
	<published>2009-12-23T13:19:28Z</published>
	<updated>2009-12-23T13:19:28Z</updated>
	<author>
		<name>Lie Ryan</name>
	</author>
	<content type="html">On 12/24/2009 7:34 AM, samwyse wrote:
&lt;br&gt;&amp;gt; I've got an app that's creating Open Office docs; if you don't know,
&lt;br&gt;&amp;gt; these are actually ZIP files with a different extension. &amp;nbsp;In my case,
&lt;br&gt;&amp;gt; like many other people, I generating from boilerplate, so only one
&lt;br&gt;&amp;gt; component (content.xml) of my ZIP file will ever change. &amp;nbsp;Instead of
&lt;br&gt;&amp;gt; creating the entire ZIP file each time, what is the cheapest way to
&lt;br&gt;&amp;gt; accomplish my goal? &amp;nbsp;I'd kind-of like to just write the first part of
&lt;br&gt;&amp;gt; the file as a binary blob, then write my bit, then write most of the
&lt;br&gt;&amp;gt; table of contents as another blob, and finally write a TOC entry for
&lt;br&gt;&amp;gt; my bit. &amp;nbsp;Has anyone ever done anything like this? &amp;nbsp;Thanks.
&lt;br&gt;&lt;br&gt;You might want to look at solid and non-solid compression. Solid 
&lt;br&gt;compression writes all files in the binary as one huge block and must be 
&lt;br&gt;compressed/decompressed as a whole, while non-solid compression writes 
&lt;br&gt;the zipped file in chunks that can be decompressed individually.
&lt;br&gt;&lt;br&gt;I don't know if there's any way to compress/decompress/recompress as 
&lt;br&gt;non-solid compression from python though. Maybe others can point 
&lt;br&gt;something out, or maybe you can use an external zipper that understands 
&lt;br&gt;non-solid compression.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/creating-ZIP-files-on-the-cheap-tp26907087p26907586.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26908218</id>
	<title>strange geometry problem</title>
	<published>2009-12-23T13:19:20Z</published>
	<updated>2009-12-23T13:19:20Z</updated>
	<author>
		<name>Nick Buchholz</name>
	</author>
	<content type="html">Hi all, 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I'm doing a GUI for describing connectors and the signals attached. &amp;nbsp;the system runs on 
&lt;br&gt;CentOS release 5.2 (FINAL) using python 2.5 and tcl/tk 8.4
&lt;br&gt;&lt;br&gt;I have a class Pin that contains two class attributes that are dialogs. They are built by a helper
&lt;br&gt;routine as follows: 
&lt;br&gt;&amp;nbsp; &amp;nbsp; if type(Pin.clkDialog) == type(None):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pin.clkDialog = bldTypeDlg(self.cnctr.gui.parent,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (&amp;quot;Clock State Selector&amp;quot;, &amp;quot;Choose a Default \nClock State\n\n\n\n&amp;quot;),
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CLKVALUES, 0)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pin.clkDialog.geometry('+%d+%d'%(400,400))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Pin.clkDialog.withdraw()
&lt;br&gt;&lt;br&gt;the second dialog is similar but with different strings passed in.
&lt;br&gt;they are activated from one field of an instance variable dialog &amp;nbsp;self.valDialog
&lt;br&gt;&lt;br&gt;The strange behavior is as follows:
&lt;br&gt;&amp;nbsp; The first time the class dialogs are activated they appear in front of but immediately go behind the 
&lt;br&gt;valDialog and are hidden. After moving the valDialog and using the class dialogs, subsequent activations
&lt;br&gt;appear at a location that is effected by the geometry spec in the activate routine.
&lt;br&gt;&lt;br&gt;the activation code is
&lt;br&gt;#####################################################################################
&lt;br&gt;#####################################################################################
&lt;br&gt;&amp;nbsp; &amp;nbsp; def getClkState(self, event):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pin.clkDialog.geometry('+%d+%d'%(400,400))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rslt = Pin.clkDialog.tkraise()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resp = Pin.clkDialog.activate()
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if resp == 'OK':
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.clkNominal = Pin.clkDialog.get()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.entries[5].setentry(self.clkNominal)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.valDisps[4].setentry( self.clkNominal &amp;nbsp;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return &amp;quot;break&amp;quot;
&lt;br&gt;&lt;br&gt;#####################################################################################
&lt;br&gt;#####################################################################################
&lt;br&gt;&amp;nbsp; &amp;nbsp; def getLgcState(self, event):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pin.lgcDialog.geometry('+%d+%d'%(400,400))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rslt = Pin.lgcDialog.tkraise()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resp = Pin.lgcDialog.activate()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if resp == 'OK':
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.lgcNominal = Pin.lgcDialog.get()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.entries[5].setentry(self.lgcNominal)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.valDisps[4].setentry( self.lgcNominal &amp;nbsp;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return &amp;quot;break&amp;quot;
&lt;br&gt;&lt;br&gt;Any ideas on what's going on? &amp;nbsp;and how to fix it?
&lt;br&gt;&lt;br&gt;&lt;br&gt;Nick
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26908218&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nbuchholz@...&lt;/a&gt;
&lt;br&gt;Day phone: (520) 318-8203
&lt;br&gt;&amp;quot;Time is an illusion, Lunchtime doubly so&amp;quot; - Ford Prefect
&lt;br&gt;Time is an illusion perpetrated by the manufacturers of space.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/strange-geometry-problem-tp26908218p26908218.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907530</id>
	<title>Re: More On the Strange Problem</title>
	<published>2009-12-23T13:13:47Z</published>
	<updated>2009-12-23T13:13:47Z</updated>
	<author>
		<name>Lie Ryan</name>
	</author>
	<content type="html">On 12/24/2009 8:00 AM, MRAB wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;&amp;gt;&amp;gt;&amp;gt; print first_twin == second_twin
&lt;br&gt;&amp;gt; True
&lt;br&gt;&lt;br&gt;err... I don't think there is any situation where first_twin == 
&lt;br&gt;second_twin wouldn't be considered a bug. They look similar, they act 
&lt;br&gt;similar, and they quack the same; though you can almost always treat 
&lt;br&gt;them the same they are still ultimately different person?
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/More-On-the-Strange-Problem-tp26905598p26907530.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907488</id>
	<title>ISO all functions+methods+classes without docstring</title>
	<published>2009-12-23T13:08:02Z</published>
	<updated>2009-12-23T13:08:02Z</updated>
	<author>
		<name>kj-16</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;I'm looking for a good way to get a listing of all the undocumented
&lt;br&gt;(i.e. docstring-less) functions, classes, and methods as defined
&lt;br&gt;in a (largish) library of files.
&lt;br&gt;&lt;br&gt;What's a good way to get this information?
&lt;br&gt;&lt;br&gt;TIA!
&lt;br&gt;&lt;br&gt;-Kynn
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/ISO-all-functions%2Bmethods%2Bclasses-without-docstring-tp26907488p26907488.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907459</id>
	<title>Re: force non-exponential representation for Decimal?</title>
	<published>2009-12-23T13:06:40Z</published>
	<updated>2009-12-23T13:06:40Z</updated>
	<author>
		<name>mensanator@aol.com</name>
	</author>
	<content type="html">On Dec 23, 4:03 am, &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26907459&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jh...@...&lt;/a&gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; (cc-ing the list)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; Is there a convenient way to force a decimal.Decimal representation to
&lt;br&gt;&amp;gt; &amp;gt; not use exponential representation?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Which Python version are you using?  For Python 2.6 (and 3.1), the
&lt;br&gt;&amp;gt; &amp;gt; answer's yes.  For earlier Python verions, I don't think so.  In
&lt;br&gt;&amp;gt; &amp;gt; Python 2.6, use new-style formatting with the 'f' modifier:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;&amp;gt;&amp;gt; '{0:f}'.format(Decimal('1e-100'))
&lt;br&gt;&amp;gt; &amp;gt; '0.000000000000000000000000000000000000000000000000000000000000000000000000­0000000000000000000000000001'
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;&amp;gt;&amp;gt; '{0:f}'.format(Decimal('1e100'))
&lt;br&gt;&amp;gt; &amp;gt; '10000000000000000000000000000000000000000000000000000000000000000000000000­000000000000000000000000000'
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Unfortunately, I'm still using Python 2.4 so I can't go that way (at least not anytime soon, this is a production environment).
&lt;/div&gt;&lt;br&gt;But you can get gmpy for Python 2.4. And then you can do:
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; c = gmpy.mpf('2.3430000000837483727772E-19')
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; c
&lt;br&gt;mpf('2.34300000008374837278e-19')
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; help(gmpy.fdigits)
&lt;br&gt;&lt;br&gt;Help on built-in function fdigits in module gmpy:
&lt;br&gt;&lt;br&gt;fdigits(...)
&lt;br&gt;&amp;nbsp; &amp;nbsp; fdigits(x, base=10, digs=0, mine=0, maxe=-1, opts=0): formats x,
&lt;br&gt;&amp;nbsp; &amp;nbsp; which is an mpf or else gets coerced to one.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; Returns up to digs digits in the given base (if digs is 0, as many
&lt;br&gt;&amp;nbsp; &amp;nbsp; digits as are available), but no more than available given x's
&lt;br&gt;&amp;nbsp; &amp;nbsp; precision; the resulting string is formatted in fixed point
&lt;br&gt;&amp;nbsp; &amp;nbsp; if the exponent is &amp;gt;=mine and &amp;lt;=maxe, else in exponential (the
&lt;br&gt;&amp;nbsp; &amp;nbsp; exponent-separator is 'e' for base up to 10, else '@' -- the
&lt;br&gt;&amp;nbsp; &amp;nbsp; exponent is always output as a signed, base-10 integer). If opts
&lt;br&gt;&amp;nbsp; &amp;nbsp; has bit 1 set, the whole is wrapped in 'gmpy.mpf(...)', to ease
&lt;br&gt;&amp;nbsp; &amp;nbsp; later approximate reconstruction via builtin function eval
&lt;br&gt;&amp;nbsp; &amp;nbsp; (Or, in just mpf(...) if gmpy.set_tagoff(1) was called).
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; If opts has bit 2 set, then opts bit 1, mine, and maxe, are
&lt;br&gt;&amp;nbsp; &amp;nbsp; ignored; the result is then a 2-element tuple, first element
&lt;br&gt;&amp;nbsp; &amp;nbsp; the raw string of base-digits without formatting, second the
&lt;br&gt;&amp;nbsp; &amp;nbsp; exponent in base as a Python int.
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; gmpy.fdigits(c,10,30,-30,30)
&lt;br&gt;'0.000000000000000000234300000008374837278'
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; For earlier Python versions, you can manipulate the output string as
&lt;br&gt;&amp;gt; &amp;gt; you describe, or you can extract the raw components of the Decimal
&lt;br&gt;&amp;gt; &amp;gt; instance (e.g. with the as_tuple() method) and construct a string
&lt;br&gt;&amp;gt; &amp;gt; directly from those.  You might be also be able to extract code for
&lt;br&gt;&amp;gt; &amp;gt; the '{:f}' formatting from the Python 2.6 Decimal source (Lib/
&lt;br&gt;&amp;gt; &amp;gt; decimal.py), but it's fairly convoluted.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks a lot for the hints, I'll look into that.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Holger
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
&lt;br&gt;&amp;gt; Jetzt freischalten unterhttp://portal.gmx.net/de/go/maxdome01
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Re%3A-force-non-exponential-representation-for-Decimal--tp26900307p26907459.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907366</id>
	<title>Re: More On the Strange Problem</title>
	<published>2009-12-23T13:00:27Z</published>
	<updated>2009-12-23T13:00:27Z</updated>
	<author>
		<name>MRAB-2</name>
	</author>
	<content type="html">Victor Subervi wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Wed, Dec 23, 2009 at 3:03 PM, MRAB &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26907366&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;python@...&lt;/a&gt; 
&lt;br&gt;&amp;gt; &amp;lt;mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26907366&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;python@...&lt;/a&gt;&amp;gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; Victor Subervi wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I've isolated the problem in the print-out at the bottom of this
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; post. It occurs when these values are passed:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ['LastDatePrice', 'date', '10', 'yyyy/mm/dd', None],
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Since this is the first datetime that is passed, it would appear
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; to be associated with such values, which are processed thus:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elif typeName == 'datetime':
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; Where does the value of typeName come from?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; It is the descriptor of the MySQL type.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print &amp;quot;&amp;lt;input type='text' width='%s' maxlength='%s'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; name='%s' value='%s' /&amp;gt; &amp;quot; \
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;&amp;lt;i&amp;gt;This field takes a datetime up to %s alphanumeric
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; characters inclusive.&amp;lt;/i&amp;gt;&amp;quot; \
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% (shortNum, str(typeNum), colName, theVal, str(typeNum))
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colName == 'LastDatePrice'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; typeNum = 10
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elif 10 &amp;lt; int(typeNum) &amp;lt; 20:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; If typeNum is 10 then 10 &amp;lt; int(typeNum) &amp;lt; 20 is False.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Thank you for catching that! However, the code is followed by an else 
&lt;br&gt;&amp;gt; clause.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;shortNum = '10'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Therefore...
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; shortNum = '10'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if whatDo == 'insert':
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;theVal = defaultVal
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;val = defaultVal
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; What's the difference between theVal and val? The names don't help me!
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; :-)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; if whatDo == 'insert':
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; theVal = defaultVal
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; val = defaultVal
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; else:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; theVal = val
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Since whatDo == 'insert'...
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; and
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; val = 'yyyy/mm/dd'
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; therefore
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; theVal = None
&lt;br&gt;&amp;gt; 
&lt;/div&gt;[snip]
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If in fact the problem has to do with the None value, how can I
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; easily substitute a different value? I tried:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if theVal == None:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; The Pythonic way is to use &amp;quot;is&amp;quot; when comparing with singletons like
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; None.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Can you please explain by example?
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;/div&gt;Singleton: there is only ever one of certain objects and using &amp;quot;is&amp;quot; lets
&lt;br&gt;you check for identity. For example, consider identical twins; they look
&lt;br&gt;the same, but are not the same person. In programming terms you could
&lt;br&gt;imagine the following scenario:
&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; print first_twin == second_twin
&lt;br&gt;True
&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; print first_twin is second_twin
&lt;br&gt;False
&lt;br&gt;&lt;br&gt;In Python by far the most common singleton is None; you should use &amp;quot;is&amp;quot;
&lt;br&gt;(or &amp;quot;is not&amp;quot;) when checking whether (or not) an object is actually None.
&lt;br&gt;There might also be a few cases where a certain implementation of Python
&lt;br&gt;might use singletons for reasons of efficiency, but they are just
&lt;br&gt;optimisations in that implementation and shouldn't be relied on. The
&lt;br&gt;rule is: if you're not checking for identity (and, as I said, by far the 
&lt;br&gt;most common use is with None), check for equality.
&lt;br&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;theVal = ''
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; but that didn't capture it.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; What do you mean by &amp;quot;didn't capture it&amp;quot;?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The output was identical to what I originally posted.
&lt;br&gt;&lt;br&gt;I recommend that you write messages and values to a log file along the
&lt;br&gt;path in the code you think it's following and then see whether it's
&lt;br&gt;doing what you think it is and with the values you think it should have.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/More-On-the-Strange-Problem-tp26905598p26907366.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907311</id>
	<title>Re: creating ZIP files on the cheap</title>
	<published>2009-12-23T12:56:26Z</published>
	<updated>2009-12-23T12:56:26Z</updated>
	<author>
		<name>David Marceau</name>
	</author>
	<content type="html">samwyse wrote:
&lt;br&gt;&amp;gt; I've got an app that's creating Open Office docs; if you don't know,
&lt;br&gt;&amp;gt; these are actually ZIP files with a different extension. &amp;nbsp;In my case,
&lt;br&gt;&amp;gt; like many other people, I generating from boilerplate, so only one
&lt;br&gt;&amp;gt; component (content.xml) of my ZIP file will ever change. &amp;nbsp;Instead of
&lt;br&gt;&amp;gt; creating the entire ZIP file each time, what is the cheapest way to
&lt;br&gt;&amp;gt; accomplish my goal? &amp;nbsp;I'd kind-of like to just write the first part of
&lt;br&gt;&amp;gt; the file as a binary blob, then write my bit, then write most of the
&lt;br&gt;&amp;gt; table of contents as another blob, and finally write a TOC entry for
&lt;br&gt;&amp;gt; my bit. &amp;nbsp;Has anyone ever done anything like this? &amp;nbsp;Thanks.
&lt;br&gt;I think you intend on using simply the command-line infozip tool from
&lt;br&gt;python system commands:
&lt;br&gt;mycmd = &amp;quot;zip -r content.xml foo.zip&amp;quot;
&lt;br&gt;mycmd = &amp;quot;zip -i your.blob foo.zip&amp;quot;
&lt;br&gt;try:
&lt;br&gt;&amp;nbsp; &amp;nbsp; mycmd = &amp;quot;zip -r content.xml foo.zip&amp;quot;
&lt;br&gt;&amp;nbsp; &amp;nbsp; retcode = call(mycmd, shell=True)
&lt;br&gt;&amp;nbsp; &amp;nbsp; mycmd = &amp;quot;zip -i your.blob foo.zip&amp;quot;
&lt;br&gt;&amp;nbsp; &amp;nbsp; retcode = call(mycmd, shell=True)
&lt;br&gt;&amp;nbsp; &amp;nbsp; if retcode &amp;lt; 0:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &amp;gt;&amp;gt;sys.stderr, &amp;quot;Child was terminated by signal&amp;quot;, -retcode
&lt;br&gt;&amp;nbsp; &amp;nbsp; else:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &amp;gt;&amp;gt;sys.stderr, &amp;quot;Child returned&amp;quot;, retcode
&lt;br&gt;except OSError, e:
&lt;br&gt;&amp;nbsp; &amp;nbsp; print &amp;gt;&amp;gt;sys.stderr, &amp;quot;Execution failed:&amp;quot;, e
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/creating-ZIP-files-on-the-cheap-tp26907087p26907311.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907243</id>
	<title>Re: Python-list Digest, Vol 75, Issue 226</title>
	<published>2009-12-23T12:47:07Z</published>
	<updated>2009-12-23T12:47:07Z</updated>
	<author>
		<name>r0g</name>
	</author>
	<content type="html">Gabriel Genellina wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; En Tue, 22 Dec 2009 16:30:58 -0300, r0g &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26907243&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;aioe.org@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt; escribió:
&lt;br&gt;&amp;gt;&amp;gt; Gabriel Genellina wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26907243&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;thatguypulkit@...&lt;/a&gt;&amp;gt; escribió:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; I am writing a script wherein I need to merge files into existing
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; tar.gz
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; files. Currently, I am using tarfile module. I extract the tar.gz to a
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; tempdir and copy the new file there and re-compress all the files back
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; into
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; a tar.gz. &amp;nbsp;Is there a better way to do it?
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Since noone answered yet: no, I don't think you can avoid to decompress
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; and recompress those files.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Erm, I always thought it was OK to simply cat gzipped files together...
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Maybe, but still I don't think this could help the OP. As I understand
&lt;br&gt;&amp;gt; the problem, originally there were e.g.: file1, file2, file3; they were
&lt;br&gt;&amp;gt; tarred into file123.tar and gzipped into file123.tar.gz. And now file2
&lt;br&gt;&amp;gt; must be replaced by a newer version. It should go into the internal .tar
&lt;br&gt;&amp;gt; file, replacing the old one; I don't see how to do that without
&lt;br&gt;&amp;gt; decompressing it. (Ok, once the tar is decompressed one might replace
&lt;br&gt;&amp;gt; the old file with the newer one in-place using the tar command, but this
&lt;br&gt;&amp;gt; cannot be done with the tarfile Python module)
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;Oh I didn't see the original posting! I agree, if files within the
&lt;br&gt;tarball need to be replaced (as opposed to more new files added) that
&lt;br&gt;can only be done on uncompressed tar archives.
&lt;br&gt;&lt;br&gt;If performance is a issue and the files aren't too gargantuan it may be
&lt;br&gt;best to de(and re)compress the gzips to memory/ramdisk rather than
&lt;br&gt;writing it all out to disk. If the files are too large for memory but
&lt;br&gt;the OP can afford a bit more storage then storing plain uncompressed
&lt;br&gt;tarballs would allow use of tar's delete, replace and append
&lt;br&gt;functionality. If that would take up too much space maybe they could use
&lt;br&gt;plain tar on a block compressed filesystem instead.
&lt;br&gt;&lt;br&gt;Cheers,
&lt;br&gt;&lt;br&gt;Roger.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Re%3A-Python-list-Digest%2C-Vol-75%2C-Issue-226-tp26878846p26907243.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907174</id>
	<title>Re: [pygtk] cannot import glib in python shell</title>
	<published>2009-12-23T12:43:35Z</published>
	<updated>2009-12-23T12:43:35Z</updated>
	<author>
		<name>John Stowers</name>
	</author>
	<content type="html">&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I think ideally what I'm requesting is to have the mingw/python/gtk
&lt;br&gt;&amp;gt; environments to be harmonized. &amp;nbsp;I'm close. &amp;nbsp;I can do the following:
&lt;br&gt;&amp;gt; python
&lt;br&gt;&amp;gt; import sys
&lt;br&gt;&amp;gt; import gtk
&lt;br&gt;&amp;gt; blah = gtk.Window(0)
&lt;br&gt;&amp;gt; blah.show()
&lt;br&gt;&amp;gt; , but when I do
&lt;br&gt;&amp;gt; import glib
&lt;br&gt;&amp;gt; ERROR!!!
&lt;br&gt;&amp;gt; if I cd to a certain dir in glib sources, there were two .py files, but
&lt;br&gt;&amp;gt; I didn't know where to place them in the python26 dir.
&lt;br&gt;&amp;gt; From that dir, I can run the python shell, import glib and then it gives
&lt;br&gt;&amp;gt; me an error about no module for gdb...so it's none stop...with regards
&lt;br&gt;&amp;gt; to the import glib issue at present.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Any help towards this would be greatly appreciated.
&lt;/div&gt;&lt;br&gt;AFAIR there has not been a release of PyGObect on windows since the
&lt;br&gt;split of functionality into the glib namespace.
&lt;br&gt;&lt;br&gt;I cleaned up the build stuff a while ago here;
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;https://bugzilla.gnome.org/show_bug.cgi?id=589671&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://bugzilla.gnome.org/show_bug.cgi?id=589671&lt;/a&gt;&lt;br&gt;&lt;br&gt;But I no longer have a windows install. Someone else will need to update
&lt;br&gt;it to HEAD and finish it off.
&lt;br&gt;&lt;br&gt;John
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/cannot-import-glib-in-python-shell-tp26905739p26907174.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26907087</id>
	<title>creating ZIP files on the cheap</title>
	<published>2009-12-23T12:34:22Z</published>
	<updated>2009-12-23T12:34:22Z</updated>
	<author>
		<name>samwyse</name>
	</author>
	<content type="html">I've got an app that's creating Open Office docs; if you don't know,
&lt;br&gt;these are actually ZIP files with a different extension. &amp;nbsp;In my case,
&lt;br&gt;like many other people, I generating from boilerplate, so only one
&lt;br&gt;component (content.xml) of my ZIP file will ever change. &amp;nbsp;Instead of
&lt;br&gt;creating the entire ZIP file each time, what is the cheapest way to
&lt;br&gt;accomplish my goal? &amp;nbsp;I'd kind-of like to just write the first part of
&lt;br&gt;the file as a binary blob, then write my bit, then write most of the
&lt;br&gt;table of contents as another blob, and finally write a TOC entry for
&lt;br&gt;my bit. &amp;nbsp;Has anyone ever done anything like this? &amp;nbsp;Thanks.
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/creating-ZIP-files-on-the-cheap-tp26907087p26907087.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26906826</id>
	<title>Re: More On the Strange Problem</title>
	<published>2009-12-23T12:13:14Z</published>
	<updated>2009-12-23T12:13:14Z</updated>
	<author>
		<name>David Marceau</name>
	</author>
	<content type="html">Victor Subervi wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Wed, Dec 23, 2009 at 2:21 PM, Victor Subervi &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26906826&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;victorsubervi@...&lt;/a&gt;&amp;gt;wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I've isolated the problem in the print-out at the bottom of this post. It
&lt;br&gt;&amp;gt;&amp;gt; occurs when these values are passed:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; ['LastDatePrice', 'date', '10', 'yyyy/mm/dd', None],
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Since this is the first datetime that is passed, it would appear to be
&lt;br&gt;&amp;gt;&amp;gt; associated with such values, which are processed thus:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; elif typeName == 'datetime':
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &amp;quot;&amp;lt;input type='text' width='%s' maxlength='%s' name='%s'
&lt;br&gt;&amp;gt;&amp;gt; value='%s' /&amp;gt; &amp;quot; \
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;quot;&amp;lt;i&amp;gt;This field takes a datetime up to %s alphanumeric characters
&lt;br&gt;&amp;gt;&amp;gt; inclusive.&amp;lt;/i&amp;gt;&amp;quot; \
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; % (shortNum, str(typeNum), colName, theVal, str(typeNum))
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; colName == 'LastDatePrice'
&lt;br&gt;&amp;gt;&amp;gt; typeNum = 10
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; elif 10 &amp;lt; int(typeNum) &amp;lt; 20:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; shortNum = '10'
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Therefore...
&lt;br&gt;&amp;gt;&amp;gt; shortNum = '10'
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; if whatDo == 'insert':
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; theVal = defaultVal
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; val = defaultVal
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Since whatDo == 'insert'...
&lt;br&gt;&amp;gt;&amp;gt; and
&lt;br&gt;&amp;gt;&amp;gt; val = 'yyyy/mm/dd'
&lt;br&gt;&amp;gt;&amp;gt; therefore
&lt;br&gt;&amp;gt;&amp;gt; theVal = None
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Now, this value of None doesn't cause any problems with the other values
&lt;br&gt;&amp;gt;&amp;gt; printed out. This is the code:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; print 'printTheForm: ', descrProds, '&amp;lt;br /&amp;gt;'
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; for value in descrProds:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; print 'value: ', value, '&amp;lt;br /&amp;gt;'
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; that produces this print-out:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; printTheForm: [['ID', 'tinyint', '5', '0', None], ['SKU', 'varchar', '40',
&lt;br&gt;&amp;gt;&amp;gt; '', None], ['Category', 'varchar', '40', '', None], ['Name', 'varchar',
&lt;br&gt;&amp;gt;&amp;gt; '50', '', None], ['Title', 'varchar', '100', '', None], ['Description',
&lt;br&gt;&amp;gt;&amp;gt; 'mediumtext', '100', '', None], ['Price', 'float', '8', '0.0', None],
&lt;br&gt;&amp;gt;&amp;gt; ['SortFactor', 'int', '4', '0', None], ['Availability', 'tinyint', '1', '0',
&lt;br&gt;&amp;gt;&amp;gt; '1'], ['OutOfStock', 'tinyint', '1', '0', '0'], ['ShipFlatFee', 'float',
&lt;br&gt;&amp;gt;&amp;gt; '5', '0.0', '0.00'], ['ShipPercentPrice', 'tinyint', '2', '0', '0'],
&lt;br&gt;&amp;gt;&amp;gt; ['ShipPercentWeight', 'tinyint', '2', '0', '0'], ['Associations', 'varchar',
&lt;br&gt;&amp;gt;&amp;gt; '40', '', None], ['TempPrice', 'tinyint', '1', '0', None], ['LastDatePrice',
&lt;br&gt;&amp;gt;&amp;gt; 'date', '10', 'yyyy/mm/dd', None], ['Weight', 'float', '7', '0.0', None],
&lt;br&gt;&amp;gt;&amp;gt; ['Metal', 'enum', ['14k gold', '18k gold', 'white gold', 'silver',
&lt;br&gt;&amp;gt;&amp;gt; 'tungsten', 'titanium'], '', None], ['PercentMetal', 'tinyint', '2', '0',
&lt;br&gt;&amp;gt;&amp;gt; None], ['colorsShadesNumbersShort', 'set', [''], '', None]]
&lt;br&gt;&amp;gt;&amp;gt; value: ['ID', 'tinyint', '5', '0', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['SKU', 'varchar', '40', '', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['Category', 'varchar', '40', '', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['Name', 'varchar', '50', '', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['Title', 'varchar', '100', '', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['Description', 'mediumtext', '100', '', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['Price', 'float', '8', '0.0', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['SortFactor', 'int', '4', '0', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['Availability', 'tinyint', '1', '0', '1']
&lt;br&gt;&amp;gt;&amp;gt; value: ['OutOfStock', 'tinyint', '1', '0', '0']
&lt;br&gt;&amp;gt;&amp;gt; value: ['ShipFlatFee', 'float', '5', '0.0', '0.00']
&lt;br&gt;&amp;gt;&amp;gt; value: ['ShipPercentPrice', 'tinyint', '2', '0', '0']
&lt;br&gt;&amp;gt;&amp;gt; value: ['ShipPercentWeight', 'tinyint', '2', '0', '0']
&lt;br&gt;&amp;gt;&amp;gt; value: ['Associations', 'varchar', '40', '', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['TempPrice', 'tinyint', '1', '0', None]
&lt;br&gt;&amp;gt;&amp;gt; value: ['LastDatePrice', 'date', '10', 'yyyy/mm/dd', None]
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; If in fact the problem has to do with the None value, how can I easily
&lt;br&gt;&amp;gt;&amp;gt; substitute a different value? I tried:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; if theVal == None:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; theVal = ''
&lt;/div&gt;Taken from: &amp;nbsp;&lt;a href=&quot;http://boodebr.org/main/python/tourist/none-empty-nothing:&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://boodebr.org/main/python/tourist/none-empty-nothing:&lt;/a&gt;&lt;br&gt;&lt;br&gt;tags = parse_file(filename)
&lt;br&gt;if tags is None:
&lt;br&gt;&amp;nbsp; &amp;nbsp; print &amp;quot;** ERROR **&amp;quot;
&lt;br&gt;elif len(tags) == 0:
&lt;br&gt;&amp;nbsp; &amp;nbsp; print &amp;quot;Empty file&amp;quot;
&lt;br&gt;else:
&lt;br&gt;&amp;nbsp; &amp;nbsp; print &amp;quot;OK!&amp;quot;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; but that didn't capture it.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Update:
&lt;br&gt;&amp;gt; It's a date value (not datetime). I updated the database to default to the
&lt;br&gt;&amp;gt; value &amp;quot;2000-01-01&amp;quot; but that didn't help (gave the same print-out as above).
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; TIA,
&lt;br&gt;&amp;gt;&amp;gt; beno
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/More-On-the-Strange-Problem-tp26905598p26906826.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26906772</id>
	<title>Re: [gtk-win32] cannot import glib in python shell</title>
	<published>2009-12-23T12:07:45Z</published>
	<updated>2009-12-23T12:07:45Z</updated>
	<author>
		<name>Tor Lillqvist</name>
	</author>
	<content type="html">&amp;gt; , but when I do
&lt;br&gt;&amp;gt; import glib
&lt;br&gt;&amp;gt; ERROR!!!
&lt;br&gt;&lt;br&gt;My Python knowledge is next to nil. You might get more help on some
&lt;br&gt;Python-specific list. Or even a pygtk-specific list.
&lt;br&gt;&lt;br&gt;&amp;gt; if I cd to a certain dir in glib sources, there were two .py files,
&lt;br&gt;&lt;br&gt;Wrong approach. And anyway, I find four .py files in current GLib
&lt;br&gt;sources. They are completely unrelated to the GLib Python binding
&lt;br&gt;which is what you want. The GLib Python binding is not in the GLib
&lt;br&gt;sources.
&lt;br&gt;&lt;br&gt;&amp;gt; but I didn't know where to place them in the python26 dir.
&lt;br&gt;&lt;br&gt;Good, because you shouldn't. Look in the Makefile.am to get an idea
&lt;br&gt;what these files are used for. Or just read them. As I said, they are
&lt;br&gt;not what you apparently think they are.
&lt;br&gt;&lt;br&gt;--tml
&lt;br&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/cannot-import-glib-in-python-shell-tp26905739p26906772.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26906728</id>
	<title>Re: More On the Strange Problem</title>
	<published>2009-12-23T12:04:02Z</published>
	<updated>2009-12-23T12:04:02Z</updated>
	<author>
		<name>Victor Subervi</name>
	</author>
	<content type="html">&lt;div class=&quot;gmail_quote&quot;&gt;On Wed, Dec 23, 2009 at 3:03 PM, MRAB &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26906728&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;python@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div class=&quot;im&quot;&gt;Victor Subervi wrote:&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
I&amp;#39;ve isolated the problem in the print-out at the bottom of this post. It occurs when these values are passed:&lt;br&gt;
&lt;br&gt;
[&amp;#39;LastDatePrice&amp;#39;, &amp;#39;date&amp;#39;, &amp;#39;10&amp;#39;, &amp;#39;yyyy/mm/dd&amp;#39;, None],&lt;br&gt;
&lt;br&gt;
Since this is the first datetime that is passed, it would appear to be associated with such values, which are processed thus:&lt;br&gt;
&lt;br&gt;
    elif typeName == &amp;#39;datetime&amp;#39;:&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;&lt;/div&gt;
Where does the value of typeName come from?&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;It is the descriptor of the MySQL type.&lt;br&gt;&lt;/div&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div class=&quot;im&quot;&gt;&lt;br&gt;
&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
      print &amp;quot;&amp;lt;input type=&amp;#39;text&amp;#39; width=&amp;#39;%s&amp;#39; maxlength=&amp;#39;%s&amp;#39; name=&amp;#39;%s&amp;#39; value=&amp;#39;%s&amp;#39; /&amp;gt; &amp;quot; \&lt;br&gt;
        &amp;quot;&amp;lt;i&amp;gt;This field takes a datetime up to %s alphanumeric characters inclusive.&amp;lt;/i&amp;gt;&amp;quot; \&lt;br&gt;
        % (shortNum, str(typeNum), colName, theVal, str(typeNum))&lt;br&gt;
&lt;br&gt;
colName == &amp;#39;LastDatePrice&amp;#39;&lt;br&gt;
typeNum = 10&lt;br&gt;
&lt;br&gt;
      elif 10 &amp;lt; int(typeNum) &amp;lt; 20:&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;&lt;/div&gt;
If typeNum is 10 then 10 &amp;lt; int(typeNum) &amp;lt; 20 is False.&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;Thank you for catching that! However, the code is followed by an else clause. &lt;br&gt;&lt;/div&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div class=&quot;im&quot;&gt;&lt;br&gt;
&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
        shortNum = &amp;#39;10&amp;#39;&lt;br&gt;
&lt;br&gt;
Therefore...&lt;br&gt;
shortNum = &amp;#39;10&amp;#39;&lt;br&gt;
&lt;br&gt;
    if whatDo == &amp;#39;insert&amp;#39;:&lt;br&gt;
      theVal = defaultVal&lt;br&gt;
      val = defaultVal&lt;br&gt;
&lt;br&gt;
&lt;/blockquote&gt;&lt;/div&gt;
What&amp;#39;s the difference between theVal and val? The names don&amp;#39;t help me!&lt;br&gt;
:-)&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;    if whatDo == &amp;#39;insert&amp;#39;:&lt;br&gt;      theVal = defaultVal&lt;br&gt;      val = defaultVal&lt;br&gt;    else:&lt;br&gt;      theVal = val&lt;br&gt;  &lt;br&gt;&lt;/div&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;div class=&quot;h5&quot;&gt;&lt;br&gt;
&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
Since whatDo == &amp;#39;insert&amp;#39;...&lt;br&gt;
and&lt;br&gt;
val = &amp;#39;yyyy/mm/dd&amp;#39;&lt;br&gt;
therefore&lt;br&gt;
theVal = None&lt;br&gt;
&lt;br&gt;
Now, this value of None doesn&amp;#39;t cause any problems with the other values printed out. This is the code:&lt;br&gt;
&lt;br&gt;
  print &amp;#39;printTheForm: &amp;#39;, descrProds, &amp;#39;&amp;lt;br /&amp;gt;&amp;#39;&lt;br&gt;
  for value in descrProds:&lt;br&gt;
    print &amp;#39;value: &amp;#39;, value, &amp;#39;&amp;lt;br /&amp;gt;&amp;#39;&lt;br&gt;
&lt;br&gt;
that produces this print-out:&lt;br&gt;
&lt;br&gt;
printTheForm: [[&amp;#39;ID&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;5&amp;#39;, &amp;#39;0&amp;#39;, None], [&amp;#39;SKU&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;40&amp;#39;, &amp;#39;&amp;#39;, None], [&amp;#39;Category&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;40&amp;#39;, &amp;#39;&amp;#39;, None], [&amp;#39;Name&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;50&amp;#39;, &amp;#39;&amp;#39;, None], [&amp;#39;Title&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;100&amp;#39;, &amp;#39;&amp;#39;, None], [&amp;#39;Description&amp;#39;, &amp;#39;mediumtext&amp;#39;, &amp;#39;100&amp;#39;, &amp;#39;&amp;#39;, None], [&amp;#39;Price&amp;#39;, &amp;#39;float&amp;#39;, &amp;#39;8&amp;#39;, &amp;#39;0.0&amp;#39;, None], [&amp;#39;SortFactor&amp;#39;, &amp;#39;int&amp;#39;, &amp;#39;4&amp;#39;, &amp;#39;0&amp;#39;, None], [&amp;#39;Availability&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;1&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;1&amp;#39;], [&amp;#39;OutOfStock&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;1&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;], [&amp;#39;ShipFlatFee&amp;#39;, &amp;#39;float&amp;#39;, &amp;#39;5&amp;#39;, &amp;#39;0.0&amp;#39;, &amp;#39;0.00&amp;#39;], [&amp;#39;ShipPercentPrice&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;2&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;], [&amp;#39;ShipPercentWeight&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;2&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;], [&amp;#39;Associations&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;40&amp;#39;, &amp;#39;&amp;#39;, None], [&amp;#39;TempPrice&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;1&amp;#39;, &amp;#39;0&amp;#39;, None], [&amp;#39;LastDatePrice&amp;#39;, &amp;#39;date&amp;#39;, &amp;#39;10&amp;#39;, &amp;#39;yyyy/mm/dd&amp;#39;, None], [&amp;#39;Weight&amp;#39;, &amp;#39;float&amp;#39;, &amp;#39;7&amp;#39;, &amp;#39;0.0&amp;#39;, None], [&amp;#39;Metal&amp;#39;, &amp;#39;enum&amp;#39;, [&amp;#39;14k gold&amp;#39;, &amp;#39;18k gold&amp;#39;, &amp;#39;white gold&amp;#39;, &amp;#39;silver&amp;#39;, &amp;#39;tungsten&amp;#39;, &amp;#39;titanium&amp;#39;], &amp;#39;&amp;#39;, None], [&amp;#39;PercentMetal&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;2&amp;#39;, &amp;#39;0&amp;#39;, None], [&amp;#39;colorsShadesNumbersShort&amp;#39;, &amp;#39;set&amp;#39;, [&amp;#39;&amp;#39;], &amp;#39;&amp;#39;, None]]&lt;br&gt;

value: [&amp;#39;ID&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;5&amp;#39;, &amp;#39;0&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;SKU&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;40&amp;#39;, &amp;#39;&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;Category&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;40&amp;#39;, &amp;#39;&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;Name&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;50&amp;#39;, &amp;#39;&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;Title&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;100&amp;#39;, &amp;#39;&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;Description&amp;#39;, &amp;#39;mediumtext&amp;#39;, &amp;#39;100&amp;#39;, &amp;#39;&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;Price&amp;#39;, &amp;#39;float&amp;#39;, &amp;#39;8&amp;#39;, &amp;#39;0.0&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;SortFactor&amp;#39;, &amp;#39;int&amp;#39;, &amp;#39;4&amp;#39;, &amp;#39;0&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;Availability&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;1&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;1&amp;#39;]&lt;br&gt;
value: [&amp;#39;OutOfStock&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;1&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;]&lt;br&gt;
value: [&amp;#39;ShipFlatFee&amp;#39;, &amp;#39;float&amp;#39;, &amp;#39;5&amp;#39;, &amp;#39;0.0&amp;#39;, &amp;#39;0.00&amp;#39;]&lt;br&gt;
value: [&amp;#39;ShipPercentPrice&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;2&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;]&lt;br&gt;
value: [&amp;#39;ShipPercentWeight&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;2&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;]&lt;br&gt;
value: [&amp;#39;Associations&amp;#39;, &amp;#39;varchar&amp;#39;, &amp;#39;40&amp;#39;, &amp;#39;&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;TempPrice&amp;#39;, &amp;#39;tinyint&amp;#39;, &amp;#39;1&amp;#39;, &amp;#39;0&amp;#39;, None]&lt;br&gt;
value: [&amp;#39;LastDatePrice&amp;#39;, &amp;#39;date&amp;#39;, &amp;#39;10&amp;#39;, &amp;#39;yyyy/mm/dd&amp;#39;, None]&lt;br&gt;
&lt;br&gt;
If in fact the problem has to do with the None value, how can I easily substitute a different value? I tried:&lt;br&gt;
&lt;br&gt;
if theVal == None:&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
The Pythonic way is to use &amp;quot;is&amp;quot; when comparing with singletons like&lt;div class=&quot;im&quot;&gt;&lt;br&gt;
None.&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;Can you please explain by example?&lt;br&gt; &lt;br&gt;&lt;/div&gt;&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;&lt;div class=&quot;im&quot;&gt;

&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;&quot;&gt;
  theVal = &amp;#39;&amp;#39;&lt;br&gt;
&lt;br&gt;
but that didn&amp;#39;t capture it.&lt;br&gt;
&lt;br&gt;
&lt;/blockquote&gt;&lt;/div&gt;
What do you mean by &amp;quot;didn&amp;#39;t capture it&amp;quot;?&lt;br&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br&gt;The output was identical to what I originally posted.&lt;br&gt;TIA,&lt;br&gt;beno&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;-- 
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/python-list&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/python-list&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/More-On-the-Strange-Problem-tp26905598p26906728.html" />
</entry>

</feed>
