<?xml version="1.0"?>
<!-- RSS generated by Radio UserLand v8.0.8 on Tue, 14 Jan 2003 02:46:55 GMT -->
<rss version="2.0">
	<channel>
		<title>Brian St. Pierre: not quite random: python</title>
		<link>http://radio.weblogs.com/0110159/categories/python/</link>
		<description>Not Quite Random: snippets of Python.</description>
		<language>en-us</language>
		<copyright>Copyright 2003 Brian St. Pierre</copyright>
		<lastBuildDate>Tue, 14 Jan 2003 02:46:55 GMT</lastBuildDate>
		<docs>http://backend.userland.com/rss</docs>
		<generator>Radio UserLand v8.0.8</generator>
		<managingEditor>radio@bstpierre.org</managingEditor>
		<webMaster>radio@bstpierre.org</webMaster>
		<category domain="http://www.weblogs.com/rssUpdates/changes.xml">rssUpdates</category> 
		<skipHours>
			<hour>1</hour>
			<hour>2</hour>
			<hour>3</hour>
			<hour>4</hour>
			<hour>5</hour>
			<hour>0</hour>
			<hour>23</hour>
			<hour>18</hour>
			</skipHours>
		<cloud domain="radio.xmlstoragesystem.com" port="80" path="/RPC2" registerProcedure="xmlStorageSystem.rssPleaseNotify" protocol="xml-rpc"/>
		<ttl>60</ttl>
		<item>
			<title>odbc.py: working with dbiRaw</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2003/01/03.html#a339</link>
			<description>&lt;p&gt;&lt;a href=&quot;http://groups.google.com/groups?selm=CAOF9.6022%24Nm.894344%40news20.bellglobal.com&amp;rnum=3&quot; title=&quot;&quot;&gt;This post on comp.lang.python&lt;/a&gt; describes how to use the dbiRaw object you get back when working with binary (BLOB or IMAGE, depending on your back end) fields. And, for some reason, I seem to be getting back two bytes for every byte inserted. This is annoying.&lt;/p&gt;
</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2003/01/03.html#a339</guid>
			<pubDate>Fri, 03 Jan 2003 22:34:15 GMT</pubDate>
			</item>
		<item>
			<title>It looks like Python 2.3 will have some pretty cool stuff. </title>
			<link>http://radio.weblogs.com/0110159/categories/python/2003/01/03.html#a338</link>
			<description>&lt;p&gt;It looks like &lt;a href=&quot;http://www.python.org/peps/pep-0283.html&quot;&gt;Python 2.3&lt;/a&gt; will have some pretty cool stuff.&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2003/01/03.html#a338</guid>
			<pubDate>Fri, 03 Jan 2003 13:34:10 GMT</pubDate>
			</item>
		<item>
			<title>Python module for handling MS Word files</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/31.html#a336</link>
			<description>&lt;p&gt;I wrote a simple &lt;a href=&quot;http://bstpierre.org/Projects/msword.py&quot;&gt;python module&lt;/a&gt; for handling MS Word files. If you&apos;ve been &lt;a href=&quot;http://radio.weblogs.com/0110159/2002/12/27.html#a319&quot;&gt;following&lt;/a&gt; &lt;a href=&quot;http://radio.weblogs.com/0110159/2002/12/16.html#a296&quot;&gt;along&lt;/a&gt;, you know that I&apos;ve been wrestling with python and Word a bit recently. It turns out that it&apos;s easy enough to do, you just have to put together the right information. (Note: requires &lt;a href=&quot;http://starship.python.net/crew/mhammond/win32/&quot;&gt;win32&lt;/a&gt; extensions, Word, and &lt;a href=&quot;http://www.panix.com/~dfoster/prog/office/fpropset/FPropSet.html&quot;&gt;FPropSet&lt;/a&gt;.)&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/31.html#a336</guid>
			<pubDate>Tue, 31 Dec 2002 12:18:30 GMT</pubDate>
			</item>
		<item>
			<title>Do Not Operate Heavy Machinery if Brain is not Working</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a320</link>
			<description>&lt;p&gt;After spending &lt;em&gt;an hour&lt;/em&gt; trying to figure out what misunderstanding of COM was causing my problem, I realized that the file I was trying to test against DID NOT EXIST (typo). I was calling everything correctly, but the information I was sending was wrong... note that setting &lt;tt&gt;fps.Pathname&lt;/tt&gt; to a non-existent file will cause an exception.&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a320</guid>
			<pubDate>Fri, 27 Dec 2002 23:33:41 GMT</pubDate>
			</item>
		<item>
			<title>Document Titles Part II: A Better Way</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a319</link>
			<description>&lt;p&gt;There is: &lt;a href=&quot;http://www.panix.com/~dfoster/prog/office/fpropset/FPropSet.html&quot;&gt;FPropSet&lt;/a&gt;. This is about two magnitudes of order faster than the previous solution.&lt;/p&gt;
&lt;pre&gt;
    fps = win32com.client.Dispatch(&apos;FilePropertySet.FilePropertySet&apos;)
    fps.Pathname = file
    print fps.BuiltInFileProperties().Item(&quot;Title&quot;)
&lt;/pre&gt;
</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a319</guid>
			<pubDate>Fri, 27 Dec 2002 23:30:51 GMT</pubDate>
			</item>
		<item>
			<title>Hmm.</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a318</link>
			<description>&lt;p&gt;Hmm. There has &lt;em&gt;got&lt;/em&gt; to be a faster way of getting that info. I&apos;m pretty sure that Explorer isn&apos;t launching Word every time it wants to display the properties for a document.&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a318</guid>
			<pubDate>Fri, 27 Dec 2002 20:47:27 GMT</pubDate>
			</item>
		<item>
			<title>Using Python to Extract Title from MS Word Doc</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a317</link>
			<description>&lt;p&gt;Based on some code from &lt;a href=&quot;http://www.experts-exchange.com/Applications/MS_Office/Q_20146327.html&quot;&gt;this article&lt;/a&gt;, here&apos;s how to extract the &amp;quot;Title&amp;quot; property from a Word document in python.&lt;/p&gt;
&lt;pre&gt;
  import win32com.client
  app = win32com.client.Dispatch(&apos;Word.Application&apos;)
  doc = app.Documents.Add(self.filename)
  self.title = doc.BuiltinDocumentProperties(&quot;Title&quot;)
  doc.Close(0)
  app.Quit()
&lt;/pre&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/27.html#a317</guid>
			<pubDate>Fri, 27 Dec 2002 20:25:43 GMT</pubDate>
			</item>
		<item>
			<title>upload.py: a script to upload files to FTP server only as-needed</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/20.html#a313</link>
			<description>&lt;p&gt;This is a &lt;a href=&quot;http://bstpierre.org/Projects/upload.py&quot;&gt;python script&lt;/a&gt; that basically implements a crude sort of &lt;a href=&quot;http://radio.weblogs.com/0100059/stories/2002/03/07/whatIsUpstreaming.html&quot;&gt;upstreaming&lt;/a&gt; (but it&apos;s not scanning &lt;a href=&quot;http://radiodiscuss.userland.com/howUpstreamingWorks&quot;&gt;constantly&lt;/a&gt;, only when you run the script). I wrote this because I got tired of fighting with other software that didn&apos;t quite integrate the way I wanted it to. This is a &lt;a href=&quot;http://www.smallpieces.com/&quot;&gt;small piece&lt;/a&gt; in a set &lt;a href=&quot;http://www.php.net/&quot;&gt;of&lt;/a&gt; &lt;a href=&quot;http://www.google.com/search?q=emacs&quot;&gt;loosely&lt;/a&gt; &lt;a href=&quot;http://www.cygwin.com/&quot;&gt;joined&lt;/a&gt; &lt;a href=&quot;http://www.python.org/&quot;&gt;tools&lt;/a&gt; that I use to manage my &lt;a href=&quot;http://bstpierre.org/&quot;&gt;website&lt;/a&gt;(&lt;a href=&quot;http://silverback-software.com/&quot;&gt;s&lt;/a&gt;). The script is available under an MIT style license.&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/20.html#a313</guid>
			<pubDate>Sat, 21 Dec 2002 00:28:25 GMT</pubDate>
			</item>
		<item>
			<title>Creating a DSN from Python</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/19.html#a305</link>
			<description>&lt;p&gt;This is pretty simple. All I did was to convert the MS KB article from Visual Basic to Python. Note that this won&apos;t actually create the .mdb file. That&apos;s a little trickier -- I can&apos;t find a Python binding for the DLL call and I don&apos;t have the need for it at the moment. See &lt;a href=&quot;http://radio.weblogs.com/0110159/gems/init_dsn_py.txt&quot;&gt;init_dsn.py&lt;/a&gt; for details.&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/19.html#a305</guid>
			<pubDate>Thu, 19 Dec 2002 20:56:05 GMT</pubDate>
			</item>
		<item>
			<title>Using the Windows System Tray with wxPython</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/18.html#a301</link>
			<description>&lt;p&gt;Check out this &lt;a href=&quot;http://radio.weblogs.com/0110159/gems/systray_py.txt&quot;&gt;code sample&lt;/a&gt; for a quick and dirty system-tray demo using wxPython. (Lifted, rearranged, and simplified from the wxPython demo.)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that you&apos;ll need an icon file for this to work, or you&apos;ll have to add back the images.py code from the demo.&lt;/em&gt;&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/18.html#a301</guid>
			<pubDate>Wed, 18 Dec 2002 16:28:00 GMT</pubDate>
			</item>
		<item>
			<title>MS Word from Python</title>
			<link>http://radio.weblogs.com/0110159/categories/python/2002/12/16.html#a296</link>
			<description>&lt;p&gt;&lt;em&gt;Note: this assumes you have &lt;a href=&quot;http://www.python.org/&quot;&gt;python&lt;/a&gt;, &lt;a href=&quot;http://starship.python.net/crew/mhammond/win32/&quot;&gt;win32all&lt;/a&gt;, and MS Word all installed properly.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Running Word from python is incredibly easy.&lt;/p&gt;
&lt;pre&gt;
import win32com.client
# Start the application.
app = win32com.client.Dispatch(&apos;Word.Application&apos;)
# Open a document.
doc = app.Documents.Add(&apos;c:\path\to\document\test.doc&apos;)
# Or:
app.ChangeFileOpenDirectory(&apos;c:\path\to\document\&apos;)
doc = app.Documents.Add(&apos;test.doc&apos;)
# To save as HTML (filtered; i.e. without most of the MS cruft)
# Note: I don&apos;t know if the type-number is portable??
doc.SaveAs(&apos;test.html&apos;, 10) ## 10 == HTML-Filtered
doc.Close(0) ## 0 == don&apos;t save changes?
app.Quit()
&lt;/pre&gt;
&lt;p&gt;This will all run &quot;invisibly&quot;. If you want to display the app while doing all of this, set &lt;tt&gt;app.Visible = 1&lt;/tt&gt; somewhere near the top. If you simply want to fetch the text from the document, use &lt;tt&gt;doc.Content.Text&lt;/tt&gt;. It will return a Unicode string and it&apos;s worth noting that those &quot;smart quotes&quot; have no representation in ASCII so you might have to be careful decoding it.&lt;/p&gt;</description>
			<guid>http://radio.weblogs.com/0110159/categories/python/2002/12/16.html#a296</guid>
			<pubDate>Mon, 16 Dec 2002 19:21:16 GMT</pubDate>
			</item>
		</channel>
	</rss>