<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Python</title>
  <link rel="alternate" type="text/html" href="http://www.jaharmi.com/topic/technology/computing/software/python"/>
  <link rel="self" type="application/atom+xml" href="http://www.jaharmi.com/taxonomy/term/14/atom/feed"/>
  <id>http://www.jaharmi.com/taxonomy/term/14/atom/feed</id>
  <updated>2008-05-20T15:55:36-05:00</updated>
  <entry>
    <title>Getting the settings right for the Drupal GeSHi Filter module</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2009/01/04/getting_settings_right_for_drupal_geshi_filter_module" />
    <id>http://www.jaharmi.com/2009/01/04/getting_settings_right_for_drupal_geshi_filter_module</id>
    <published>2009-01-04T21:20:04-06:00</published>
    <updated>2009-01-04T21:21:57-06:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="AppleScript" />
    <category term="Computing" />
    <category term="Design" />
    <category term="Discovery" />
    <category term="Drupal" />
    <category term="Open source" />
    <category term="PHP" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Shell" />
    <category term="Software" />
    <category term="System administration" />
    <category term="Tagging" />
    <category term="UNIX" />
    <category term="Web" />
    <category term="Irreality" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>I wanted to find a way to do syntax highlighting of code snippets on my Drupal blog. I came across the <a class="freelinking external" href="http://drupal.org/project/geshifilter">GeSHi Filter</a> module, which lets <a class="freelinking external" href="http://drupal.org/">Drupal</a> sites take advantage of the apparently well-regarded <a class="freelinking external" href="http://qbnz.com/highlighter/">GeSHi</a> Generic Syntax Highlighter library that&rsquo;s meant for just this purpose.<br />
However, I ran into some roadblocks implementing it on my site. Here&rsquo;s the short story of what I settled on after some trial and error.<br />
My existing code snippets are in &lt;code&gt; blocks, and the initial GeSHi Filter settings applied badly to them. I made the decision to only use GeSHi on &lt;blockcode&gt; blocks, since I wasn&rsquo;t using that tag yet and it wouldn&rsquo;t conflict with the snippets already posted.<br />
I most commonly write Bash/Zsh, Python, and AppleScript snippets on my blog. However, the Bash code I was using as part of my trial and error simply wasn&rsquo;t highlighting; it was coming through as the default (and boring) plain text &mdash; but was at least boxed off from the rest of the blog post.<br />
I thought that GeSHi wasn't correctly discovering that the code was written in UNIX shell syntax. I couldn&rsquo;t find a way to specify the language for that blockcode tag, until I did some searching on the &rsquo;net. To change my blockquotes to choose a certain language &mdash; at least for the purposes of this Drupal module, if not for GeSHI in general &mdash; I needed to add the &ldquo;lang=<em>lang</em>&rdquo; style to the tag. For Bash, I could use &ldquo;lang=bash,&rdquo; for Python, &ldquo;lang=python,&rdquo; and for AppleScript, &ldquo;lang=applescript.&rdquo; That made sense.<br />
However, my code was <em>still</em> not being syntax highlighted. I discovered that the Drupal module came with an initial set of languages enabled. The others were all turned off, but that could be changed in the module settings. Without turning them on, even properly-tagged &lt;blockcode&gt; sections did not get the benefit of syntax highlighting.<br />
I changed the GeSHi Filter options to enable some of the languages that were initially disabled, and then disabled the ones I didn&rsquo;t anticipate using. This allowed me to add Bash and AppleScript syntax highlighting support, as both had been turned off by default. After that, I saw the results I&rsquo;d hoped for: a syntax-highlighted code snippet.<br />
It took some work, but now that it&rsquo;s done, I should be all set.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I wanted to find a way to do syntax highlighting of code snippets on my Drupal blog. I came across the <a class="freelinking external" href="http://drupal.org/project/geshifilter">GeSHi Filter</a> module, which lets <a class="freelinking external" href="http://drupal.org/">Drupal</a> sites take advantage of the apparently well-regarded <a class="freelinking external" href="http://qbnz.com/highlighter/">GeSHi</a> Generic Syntax Highlighter library that&rsquo;s meant for just this purpose.</p>
<p>However, I ran into some roadblocks implementing it on my site. Here&rsquo;s the short story of what I settled on after some trial and error.</p>
<p>My existing code snippets are in &lt;code&gt; blocks, and the initial GeSHi Filter settings applied badly to them. I made the decision to only use GeSHi on &lt;blockcode&gt; blocks, since I wasn&rsquo;t using that tag yet and it wouldn&rsquo;t conflict with the snippets already posted.</p>
<p>I most commonly write Bash/Zsh, Python, and AppleScript snippets on my blog. However, the Bash code I was using as part of my trial and error simply wasn&rsquo;t highlighting; it was coming through as the default (and boring) plain text &mdash; but was at least boxed off from the rest of the blog post.</p>
<p>I thought that GeSHi wasn't correctly discovering that the code was written in UNIX shell syntax. I couldn&rsquo;t find a way to specify the language for that blockcode tag, until I did some searching on the &rsquo;net. To change my blockquotes to choose a certain language &mdash; at least for the purposes of this Drupal module, if not for GeSHI in general &mdash; I needed to add the &ldquo;lang=<em>lang</em>&rdquo; style to the tag. For Bash, I could use &ldquo;lang=bash,&rdquo; for Python, &ldquo;lang=python,&rdquo; and for AppleScript, &ldquo;lang=applescript.&rdquo; That made sense.</p>
<p>However, my code was <em>still</em> not being syntax highlighted. I discovered that the Drupal module came with an initial set of languages enabled. The others were all turned off, but that could be changed in the module settings. Without turning them on, even properly-tagged &lt;blockcode&gt; sections did not get the benefit of syntax highlighting.</p>
<p>I changed the GeSHi Filter options to enable some of the languages that were initially disabled, and then disabled the ones I didn&rsquo;t anticipate using. This allowed me to add Bash and AppleScript syntax highlighting support, as both had been turned off by default. After that, I saw the results I&rsquo;d hoped for: a syntax-highlighted code snippet.</p>
<p>It took some work, but now that it&rsquo;s done, I should be all set.</p>
    ]]></content>
  </entry>
  <entry>
    <title>An Epic Introduction to PyObjC and Cocoa</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/12/03/an_epic_introduction_to_pyobjc_and_cocoa" />
    <id>http://www.jaharmi.com/2008/12/03/an_epic_introduction_to_pyobjc_and_cocoa</id>
    <published>2008-12-03T22:42:37-06:00</published>
    <updated>2008-12-03T15:42:40-06:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Computing" />
    <category term="Mac OS X" />
    <category term="Macintosh" />
    <category term="Open source" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Software" />
    <category term="Leopard" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>Irrational Exuberance has <a href="http://lethain.com/entry/2008/aug/22/an-epic-introduction-to-pyobjc-and-cocoa/" title="An Epic Introduction to PyObjC and Cocoa @ Irrational Exuberance">An Epic Introduction to PyObjC and Cocoa</a>. Skimming over it, it really does seem to start at the ground level &mdash; and that&rsquo;s what I need. I have high hopes it will help me figure out PyObjC.<br />
[Via <a href="http://pyobjc.sourceforge.net/" title="PyObjC Development mailing list">PyObjC Development mailing list</a>.]</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Irrational Exuberance has <a href="http://lethain.com/entry/2008/aug/22/an-epic-introduction-to-pyobjc-and-cocoa/" title="An Epic Introduction to PyObjC and Cocoa @ Irrational Exuberance">An Epic Introduction to PyObjC and Cocoa</a>. Skimming over it, it really does seem to start at the ground level &mdash; and that&rsquo;s what I need. I have high hopes it will help me figure out PyObjC.</p>
<p>[Via <a href="http://pyobjc.sourceforge.net/" title="PyObjC Development mailing list">PyObjC Development mailing list</a>.]</p>
    ]]></content>
  </entry>
  <entry>
    <title>List changed files in a Mercurial repository with a custom output style</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/11/30/list_changed_files_in_a_mercurial_repository_with_a_custom_output_style" />
    <id>http://www.jaharmi.com/2008/11/30/list_changed_files_in_a_mercurial_repository_with_a_custom_output_style</id>
    <published>2008-11-30T09:51:18-06:00</published>
    <updated>2008-11-30T14:31:59-06:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Computing" />
    <category term="Discovery" />
    <category term="Drupal" />
    <category term="Mac OS X" />
    <category term="Mercurial" />
    <category term="Open source" />
    <category term="Python" />
    <category term="Shell" />
    <category term="Software" />
    <category term="System administration" />
    <category term="Version control" />
    <category term="Web" />
    <category term="Leopard" />
    <category term="Logging" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>While trying to troubleshoot what I’d done to mess up the <a class="freelinking external" href="http://www.selenic.com/mercurial/">Mercurial</a> repositories managing my Drupal installations last weekend, I <em>really</em> would have liked a way to see what files had changes in specific revisions. Each revision to a Mercurial repository affects some files, of course, but it seems awfully hard to figure what files changed in that check-in.<br />
I have since found a way to do that by <a class="freelinking external" href="http://hgbook.red-bean.com/hgbookch11.html">customizing the output of Mercurial</a>. To customize output, you can create templates on the command line (with --template) or for more powerful reformatting, create an output style file.<br />
I struggled for a while to figure out how to use style files, and eventually came up with something that works for me so far.<br />
Since I’ve installed Mercurial from Lee Cantey’s <a class="freelinking external" href="http://mercurial.berkwood.com/">standard binary package for Mac OS X Leopard</a>, I created the file “map-cmdline.changedfiles” at the “/Library/Python/2.5/site-packages/mercurial/templates” path. (Where you put the file may vary depending on where Mercurial is installed, and I’m sorry but I don’t know where it gets installed on other systems.) The contents of “map-cmdline.changedfiles” are below, along with my possibly inept description of what each line is doing:<br />
<code type="bash"># Get all of the files in the selected revision<br />
# and stringify them, whatever that means<br />
# but do not 'tabindent' or wrap them to 68/76 columns<br />
# Without first setting changeset to the list of files<br />
# you won't get output from subsequent lines<br />
<strong>changeset = '{files|stringify}</strong>'<br />
# List modified files, one per line<br />
# preceded by M to mimic `hg status`<br />
<strong>file = 'M {file}\n'</strong><br />
<strong>last_file = 'M {file}\n'</strong><br />
# List added files, one per line<br />
# preceded by A to mimic `hg status`<br />
<strong>file_add = 'A {file_add}\n'</strong><br />
<strong>last_file_add = 'A {file_add}\n'</strong><br />
# List deleted files, one per line<br />
# preceded by ! to mimic `hg status`<br />
<strong>file_del = '! {file_del}\n'</strong><br />
<strong>last_file_del = '! {file_del}\n'</strong></code><br />
I don’t know why the “map-cmdline.” portion of the filename is there, but as long as I have it, I can call the style file from the command line with what follows the period. So, I can call the style with “--style changedfiles” — and that tiny bit of voodoo seems reasonable enough to me. (The other styles in the directory above, many of which end in “.tmpl” extensions, seem related to the Mercurial Web server, hgweb. I tried, but I couldn’t use their names at the command line, with or without their extensions. Plus, their contents looked HTML-ish.)<br />
With the “map-cmdline.changedfiles” style file saved in that location, I can call Mercurial’s “log” command:<br />
<code>$ <strong>hg log --style changedfiles -r <em>tip</em></strong></code><br />
… which gives me a list of the files changed in the “tip” (or latest revision) of the repository. I could substitute in any revision identifier for “tip.”<br />
I haven’t actually seen the “file_add” and “file_del” keywords in action; every time I’ve used this style file in the manner described, I’ve only seen files marked as “M” — even if I’m looking at a revision where new files were first checked into the repo. I’m confused by that, but I’m not going to let it sour my day at this point.<br />
There might have been an easier way to do this but I didn’t find one last weekend. It took me some time to figure even this bit out, and I hope writing this post saves someone new to Mercurial from future frustration.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>While trying to troubleshoot what I’d done to mess up the <a class="freelinking external" href="http://www.selenic.com/mercurial/">Mercurial</a> repositories managing my Drupal installations last weekend, I <em>really</em> would have liked a way to see what files had changes in specific revisions. Each revision to a Mercurial repository affects some files, of course, but it seems awfully hard to figure what files changed in that check-in.</p>
<p>I have since found a way to do that by <a class="freelinking external" href="http://hgbook.red-bean.com/hgbookch11.html">customizing the output of Mercurial</a>. To customize output, you can create templates on the command line (with --template) or for more powerful reformatting, create an output style file.</p>
<p>I struggled for a while to figure out how to use style files, and eventually came up with something that works for me so far.</p>
<p>Since I’ve installed Mercurial from Lee Cantey’s <a class="freelinking external" href="http://mercurial.berkwood.com/">standard binary package for Mac OS X Leopard</a>, I created the file “map-cmdline.changedfiles” at the “/Library/Python/2.5/site-packages/mercurial/templates” path. (Where you put the file may vary depending on where Mercurial is installed, and I’m sorry but I don’t know where it gets installed on other systems.) The contents of “map-cmdline.changedfiles” are below, along with my possibly inept description of what each line is doing:</p>
<p><code type="bash"># Get all of the files in the selected revision<br />
# and stringify them, whatever that means<br />
# but do not 'tabindent' or wrap them to 68/76 columns<br />
# Without first setting changeset to the list of files<br />
# you won't get output from subsequent lines<br />
<strong>changeset = '{files|stringify}</strong>'<br />
# List modified files, one per line<br />
# preceded by M to mimic `hg status`<br />
<strong>file = 'M {file}\n'</strong><br />
<strong>last_file = 'M {file}\n'</strong><br />
# List added files, one per line<br />
# preceded by A to mimic `hg status`<br />
<strong>file_add = 'A {file_add}\n'</strong><br />
<strong>last_file_add = 'A {file_add}\n'</strong><br />
# List deleted files, one per line<br />
# preceded by ! to mimic `hg status`<br />
<strong>file_del = '! {file_del}\n'</strong><br />
<strong>last_file_del = '! {file_del}\n'</strong></code></p>
<p>I don’t know why the “map-cmdline.” portion of the filename is there, but as long as I have it, I can call the style file from the command line with what follows the period. So, I can call the style with “--style changedfiles” — and that tiny bit of voodoo seems reasonable enough to me. (The other styles in the directory above, many of which end in “.tmpl” extensions, seem related to the Mercurial Web server, hgweb. I tried, but I couldn’t use their names at the command line, with or without their extensions. Plus, their contents looked HTML-ish.)</p>
<p>With the “map-cmdline.changedfiles” style file saved in that location, I can call Mercurial’s “log” command:</p>
<p><code>$ <strong>hg log --style changedfiles -r <em>tip</em></strong></code></p>
<p>… which gives me a list of the files changed in the “tip” (or latest revision) of the repository. I could substitute in any revision identifier for “tip.”</p>
<p>I haven’t actually seen the “file_add” and “file_del” keywords in action; every time I’ve used this style file in the manner described, I’ve only seen files marked as “M” — even if I’m looking at a revision where new files were first checked into the repo. I’m confused by that, but I’m not going to let it sour my day at this point.</p>
<p>There might have been an easier way to do this but I didn’t find one last weekend. It took me some time to figure even this bit out, and I hope writing this post saves someone new to Mercurial from future frustration.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Conditionally import a Python module if it is available</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/10/02/conditionally_import_python_module_if_it_is_available" />
    <id>http://www.jaharmi.com/2008/10/02/conditionally_import_python_module_if_it_is_available</id>
    <published>2008-10-02T21:35:10-05:00</published>
    <updated>2008-10-02T14:41:15-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Computing" />
    <category term="Discovery" />
    <category term="Open source" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Software" />
    <category term="System administration" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>I have been struggling with the issue of module availability in Python. While the &ldquo;batteries included&rdquo; nature of the standard library is great, there are occasionally times when I need to resort to a module that isn&rsquo;t included with Python.<br />
There are also times where I&rsquo;m using modules whose status has changed. I expect that to happen more in the eventual transition to Python 2.6 and 3.0, because I&rsquo;ve used modules that are being deprecated.<br />
So I wondered how I could conditionally import a module if it was available, without stopping the flow of my scripts &mdash; and gracefully handle situations where it is missing. And here&rsquo;s one basic answer: use a &ldquo;try&rdquo; block to catch the &ldquo;ImportError&rdquo; exception. For example, if I were concerned that <a class="freelinking external" href="http://www.dnspython.org/">DNSPython</a> wasn&rsquo;t going to be installed on my target system:<br />
<code>try:<br />
import dns.resolver <em># Import DNSPython</em><br />
dnspython_available = True<br />
except ImportError:<br />
dnspython_available = False</code><br />
The &ldquo;except ImportError&rdquo; clause could specify a different module to load, or other workarounds entirely. You could map the namespaces in the &ldquo;try&rdquo; bock so the rest of your script doesn&rsquo;t notice the change in module functions, if you have a way to work around the missing module. Perhaps, you could even try to obtain and install the module, at least for temporary use by your script.<br />
Thanks to authors of the article <a class="freelinking external" href="http://www.mbmproject.com/tbtricks/python_modules.php">Python modules &#8211; how do they work?</a> for the assist. The information under heading 2.11, &ldquo;Is my module available?&rdquo; answered my question and has given me something to think about.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I have been struggling with the issue of module availability in Python. While the &ldquo;batteries included&rdquo; nature of the standard library is great, there are occasionally times when I need to resort to a module that isn&rsquo;t included with Python. </p>
<p>There are also times where I&rsquo;m using modules whose status has changed. I expect that to happen more in the eventual transition to Python 2.6 and 3.0, because I&rsquo;ve used modules that are being deprecated.</p>
<p>So I wondered how I could conditionally import a module if it was available, without stopping the flow of my scripts &mdash; and gracefully handle situations where it is missing. And here&rsquo;s one basic answer: use a &ldquo;try&rdquo; block to catch the &ldquo;ImportError&rdquo; exception. For example, if I were concerned that <a class="freelinking external" href="http://www.dnspython.org/">DNSPython</a> wasn&rsquo;t going to be installed on my target system:</p>
<p><code>try:<br />
import dns.resolver <em># Import DNSPython</em><br />
dnspython_available = True<br />
except ImportError:<br />
dnspython_available = False</code></p>
<p>The &ldquo;except ImportError&rdquo; clause could specify a different module to load, or other workarounds entirely. You could map the namespaces in the &ldquo;try&rdquo; bock so the rest of your script doesn&rsquo;t notice the change in module functions, if you have a way to work around the missing module. Perhaps, you could even try to obtain and install the module, at least for temporary use by your script.</p>
<p>Thanks to authors of the article <a class="freelinking external" href="http://www.mbmproject.com/tbtricks/python_modules.php">Python modules &#8211; how do they work?</a> for the assist. The information under heading 2.11, &ldquo;Is my module available?&rdquo; answered my question and has given me something to think about.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Mac OS X Service to create the man page URL for a command</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/07/24/mac_os_x_service_to_create_the_man_page_url_for_a_command" />
    <id>http://www.jaharmi.com/2008/07/24/mac_os_x_service_to_create_the_man_page_url_for_a_command</id>
    <published>2008-07-24T19:41:27-05:00</published>
    <updated>2008-07-25T09:34:37-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Computing" />
    <category term="Mac OS X" />
    <category term="Macintosh" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Software" />
    <category term="Leopard" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>Mac OS X has a type of URL specifically for opening UNIX man pages. For me, using one of these URLs opens a new Terminal window to display the man page. Just put the name of the man page after the &ldquo;x-man-page://&rdquo; URL scheme to create one of these URLs.<br />
For example, a link to the rsync man page would look like &ldquo;x-man-page://rsync&rdquo; when written out.<br />
This is a handy way to refer to UNIX man pages with other Mac OS X users in e-mail correspondence, on mailing lists, or on the Web. Because of that, I wanted a quicker way to create these man page URLs. I wrote the <a class="freelinking external" href="http://www.jaharmi.com/files/ManPageUrlForCommand.zip">Mac OS X Service named &ldquo;Man Page URL for Command&rdquo;</a> to satisfy that desire. The &ldquo;Man Page URL for Command&rdquo; Service is provided &ldquo;as-is&rdquo; with no warranty.<br />
The Service was wrapped up with <a class="freelinking external" href="http://wafflesoftware.net/thisservice/">ThisService</a> by Peter Hosey, as with my earlier <a href="/freelinking/Mac%2520OS%2520X%2520Service%2520to%2520shorten%2520a%2520URL%2520with%2520Bit.ly" class="freelinking">Mac OS X Service to shorten a URL with Bit.ly</a>.<br />
To install the Service:</p>
<ol>
<li>Unzip the downloaded file.</li>
<li>Drag the unzipped Service to /Library/Services (for all users) or ~/Library/Services (for just the current user).</li>
</ol>
<p>To use it:</p>
<ol>
<li>Select a single word from some text you can highlight in an application. The word should ideally correspond to the name of a general UNIX command (&ldquo;ls&rdquo;), a Mac OS X-specific command (&ldquo;dsmemberutil&rdquo;), or another term the matches a man page (&ldquo;sshd_config&rdquo;). The Service is specifically coded to work only when you select a single word; if you select a text string with any white space in it, the Service will just return your original text. The Service also checks to ensure that the selected word corresponds to either a command in the $PATH or an existing man page, so it will <em>not</em> generate a &ldquo;x-man-page://&rdquo; for just <em>any</em> word.</li>
<li>Choose &ldquo;Man Page URL for Command&rdquo; from the Services submenu of the application menu. As long as you have selected only a single word that matches a command or existing man page, the selection will be replaced with the &ldquo;x-man-page://&rdquo; URL.</li>
</ol>
<p>Thanks to <a class="freelinking external" href="http://explanatorygap.net/">Nigel</a> for <a class="freelinking external" href="http://lists.psu.edu/cgi-bin/wa?A2=ind0807&amp;L=MACENTERPRISE&amp;P=R41544">the inspiration</a>.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Mac OS X has a type of URL specifically for opening UNIX man pages. For me, using one of these URLs opens a new Terminal window to display the man page. Just put the name of the man page after the &ldquo;x-man-page://&rdquo; URL scheme to create one of these URLs.</p>
<p>For example, a link to the rsync man page would look like &ldquo;x-man-page://rsync&rdquo; when written out.</p>
<p>This is a handy way to refer to UNIX man pages with other Mac OS X users in e-mail correspondence, on mailing lists, or on the Web. Because of that, I wanted a quicker way to create these man page URLs. I wrote the <a class="freelinking external" href="http://www.jaharmi.com/files/ManPageUrlForCommand.zip">Mac OS X Service named &ldquo;Man Page URL for Command&rdquo;</a> to satisfy that desire. The &ldquo;Man Page URL for Command&rdquo; Service is provided &ldquo;as-is&rdquo; with no warranty.</p>
<p>The Service was wrapped up with <a class="freelinking external" href="http://wafflesoftware.net/thisservice/">ThisService</a> by Peter Hosey, as with my earlier <a href="/freelinking/Mac%2520OS%2520X%2520Service%2520to%2520shorten%2520a%2520URL%2520with%2520Bit.ly" class="freelinking">Mac OS X Service to shorten a URL with Bit.ly</a>.</p>
<p>To install the Service:</p>
<ol>
<li>Unzip the downloaded file.</li>
<li>Drag the unzipped Service to /Library/Services (for all users) or ~/Library/Services (for just the current user).</li>
</ol>
<p>To use it:</p>
<ol>
<li>Select a single word from some text you can highlight in an application. The word should ideally correspond to the name of a general UNIX command (&ldquo;ls&rdquo;), a Mac OS X-specific command (&ldquo;dsmemberutil&rdquo;), or another term the matches a man page (&ldquo;sshd_config&rdquo;). The Service is specifically coded to work only when you select a single word; if you select a text string with any white space in it, the Service will just return your original text. The Service also checks to ensure that the selected word corresponds to either a command in the $PATH or an existing man page, so it will <em>not</em> generate a &ldquo;x-man-page://&rdquo; for just <em>any</em> word.</li>
<li>Choose &ldquo;Man Page URL for Command&rdquo; from the Services submenu of the application menu. As long as you have selected only a single word that matches a command or existing man page, the selection will be replaced with the &ldquo;x-man-page://&rdquo; URL.</li>
</ol>
<p>Thanks to <a class="freelinking external" href="http://explanatorygap.net/">Nigel</a> for <a class="freelinking external" href="http://lists.psu.edu/cgi-bin/wa?A2=ind0807&amp;L=MACENTERPRISE&amp;P=R41544">the inspiration</a>.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Mac OS X Service to shorten a URL with Bit.ly</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/07/16/mac_os_x_service_to_shorten_a_url_with_bit_ly" />
    <id>http://www.jaharmi.com/2008/07/16/mac_os_x_service_to_shorten_a_url_with_bit_ly</id>
    <published>2008-07-16T20:58:06-05:00</published>
    <updated>2008-07-24T20:04:44-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Computing" />
    <category term="Exploration" />
    <category term="Mac OS X" />
    <category term="Macintosh" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Software" />
    <category term="Web" />
    <category term="Leopard" />
    <category term="ThisService" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>Since the <a class="freelinking external" href="http://bit.ly/">Bit.ly</a> URL-shortening service is all the rage lately, and I hadn&rsquo;t seen anyone create a Mac OS X Service for it yet, I decided to try my hand at it.<br />
<a class="freelinking external" href="http://www.jaharmi.com/files/ShortenUrlWithBitly.zip">Here&rsquo;s the result.</a> The core is a relatively simple Python script and requires Mac OS X 10.5 (or Python 2.5 if you have an earlier version of Mac OS X). The Service was wrapped up with <a class="freelinking external" href="http://wafflesoftware.net/thisservice/">ThisService</a> by Peter Hosey. It&rsquo;s my first attempt at creating a Mac OS X Service &mdash; with or without ThisService &mdash; and I hope it works for you. However, it is provided &ldquo;as-is&rdquo; with no warranty.<br />
That said, if you have comments or suggestions, please feel free to <a class="freelinking external" href="http://www.jaharmi.com/contact">contact me</a>.<br />
Also, I&rsquo;m not counting this as an endorsement of Bit.ly; I just looked at info on their site and thought I could probably script it and, as you can see, I did.<br />
To install the Service:</p>
<ol>
<li>Unzip the downloaded file.</li>
<li>Drag the unzipped Service to /Library/Services (for all users) or ~/Library/Services (for just the current user).</li>
</ol>
<p>To use it:</p>
<ol>
<li>Select the full text of an &ldquo;http&rdquo; or &ldquo;https&rdquo; URL that you&rsquo;d like to shorten. (Don&rsquo;t just select a site&rsquo;s domain name. The Service is specifically coded to work on full URLs starting with &ldquo;http&rdquo; or &ldquo;https.&rdquo; So, &ldquo;www.jaharmi.com&rdquo; will not work but &ldquo;http://www.jaharmi.com&rdquo; will.)</li>
<li>Choose &ldquo;Shorten URL with Bit.ly&rdquo; from the Services submenu of the application menu. The selected URL will be <em>replaced</em> with the text of the shortened URL from Bit.ly. If it is not, the original URL will remain.</li>
</ol>
<p>Of special note, however, is that if you shorten URLs with Bit.ly this way rather than through your browser, you probably won&rsquo;t see them show up in your history (the most recent 15 URLs you&rsquo;ve shortened). The script just shortens URLs for you and does so outside of your browser, so whatever cookies or other tracking Bit.ly is doing to generate your history, it doesn&rsquo;t appear to carry over when using this simple little Service.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Since the <a class="freelinking external" href="http://bit.ly/">Bit.ly</a> URL-shortening service is all the rage lately, and I hadn&rsquo;t seen anyone create a Mac OS X Service for it yet, I decided to try my hand at it.</p>
<p><a class="freelinking external" href="http://www.jaharmi.com/files/ShortenUrlWithBitly.zip">Here&rsquo;s the result.</a> The core is a relatively simple Python script and requires Mac OS X 10.5 (or Python 2.5 if you have an earlier version of Mac OS X). The Service was wrapped up with <a class="freelinking external" href="http://wafflesoftware.net/thisservice/">ThisService</a> by Peter Hosey. It&rsquo;s my first attempt at creating a Mac OS X Service &mdash; with or without ThisService &mdash; and I hope it works for you. However, it is provided &ldquo;as-is&rdquo; with no warranty.</p>
<p>That said, if you have comments or suggestions, please feel free to <a class="freelinking external" href="http://www.jaharmi.com/contact">contact me</a>.</p>
<p>Also, I&rsquo;m not counting this as an endorsement of Bit.ly; I just looked at info on their site and thought I could probably script it and, as you can see, I did.</p>
<p>To install the Service:</p>
<ol>
<li>Unzip the downloaded file.</li>
<li>Drag the unzipped Service to /Library/Services (for all users) or ~/Library/Services (for just the current user).</li>
</ol>
<p>To use it:</p>
<ol>
<li>Select the full text of an &ldquo;http&rdquo; or &ldquo;https&rdquo; URL that you&rsquo;d like to shorten. (Don&rsquo;t just select a site&rsquo;s domain name. The Service is specifically coded to work on full URLs starting with &ldquo;http&rdquo; or &ldquo;https.&rdquo; So, &ldquo;www.jaharmi.com&rdquo; will not work but &ldquo;http://www.jaharmi.com&rdquo; will.)</li>
<li>Choose &ldquo;Shorten URL with Bit.ly&rdquo; from the Services submenu of the application menu. The selected URL will be <em>replaced</em> with the text of the shortened URL from Bit.ly. If it is not, the original URL will remain.</li>
</ol>
<p>Of special note, however, is that if you shorten URLs with Bit.ly this way rather than through your browser, you probably won&rsquo;t see them show up in your history (the most recent 15 URLs you&rsquo;ve shortened). The script just shortens URLs for you and does so outside of your browser, so whatever cookies or other tracking Bit.ly is doing to generate your history, it doesn&rsquo;t appear to carry over when using this simple little Service.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Python to remove commands module and some Mac-specific modules</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/05/28/python_to_remove_commands_module_and_some_mac_specific_modules" />
    <id>http://www.jaharmi.com/2008/05/28/python_to_remove_commands_module_and_some_mac_specific_modules</id>
    <published>2008-05-28T20:46:43-05:00</published>
    <updated>2008-05-28T20:46:45-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Tiger" />
    <category term="Computing" />
    <category term="Discovery" />
    <category term="Linux" />
    <category term="Mac OS X" />
    <category term="Macintosh" />
    <category term="Open source" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Shell" />
    <category term="Software" />
    <category term="System administration" />
    <category term="UNIX" />
    <category term="Leopard" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>Drat! I&rsquo;ve learned that the <code>commands</code> module for Python, which I use, <a class="freelinking external" href="http://python.org/dev/peps/pep-3108/">is deprecated and removed in Python according to PEP 3108</a>. That means I can no longer safely call <code>commands.getstatusoutput()</code> anymore. I&rsquo;ve frequently used this call in the past because it seemed the sanest, easiest way to call for a shell utility and get both its output and return status (for success or error).<br />
I&rsquo;ll have to find some other way to perform the same function &mdash; preferably one that will work on Python 2.3 from Mac OS X Tiger, Python 2.5.1 from Leopard, and future Pythons. The stated replacement for a number of similar modules (including <code>popen2</code>, which frankly kind-of frightened me off with its name) is the <a class="freelinking external" href="http://www.python.org/dev/peps/pep-0324/">subprocess module from PEP 324</a>, but I don&rsquo;t know if that will work for my purposes.<br />
There are also a bunch of Mac-specific modules being removed. I don&rsquo;t use any of them right now, but that doesn&rsquo;t mean they wouldn&rsquo;t have been useful.<br />
This kind of thing is spirit-crushing to me for some reason. I&rsquo;m especially annoyed that Python has been around for so long and it is <em>still</em> reorganizing the ways it calls <em>shell commands</em>. Just settle on something! It seems hard to take it seriously as a system administration scripting language when things like this happen.<br />
On the other hand, I love so much of the Python Standard Library, which has afforded me a lot for system administration &#8230;</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Drat! I&rsquo;ve learned that the <code>commands</code> module for Python, which I use, <a class="freelinking external" href="http://python.org/dev/peps/pep-3108/">is deprecated and removed in Python according to PEP 3108</a>. That means I can no longer safely call <code>commands.getstatusoutput()</code> anymore. I&rsquo;ve frequently used this call in the past because it seemed the sanest, easiest way to call for a shell utility and get both its output and return status (for success or error).</p>
<p>I&rsquo;ll have to find some other way to perform the same function &mdash; preferably one that will work on Python 2.3 from Mac OS X Tiger, Python 2.5.1 from Leopard, and future Pythons. The stated replacement for a number of similar modules (including <code>popen2</code>, which frankly kind-of frightened me off with its name) is the <a class="freelinking external" href="http://www.python.org/dev/peps/pep-0324/">subprocess module from PEP 324</a>, but I don&rsquo;t know if that will work for my purposes.</p>
<p>There are also a bunch of Mac-specific modules being removed. I don&rsquo;t use any of them right now, but that doesn&rsquo;t mean they wouldn&rsquo;t have been useful.</p>
<p>This kind of thing is spirit-crushing to me for some reason. I&rsquo;m especially annoyed that Python has been around for so long and it is <em>still</em> reorganizing the ways it calls <em>shell commands</em>. Just settle on something! It seems hard to take it seriously as a system administration scripting language when things like this happen.</p>
<p>On the other hand, I love so much of the Python Standard Library, which has afforded me a lot for system administration &#8230;</p>
    ]]></content>
  </entry>
  <entry>
    <title>Radmind server logging and the repo command</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/05/28/radmind_server_logging_and_the_repo_command" />
    <id>http://www.jaharmi.com/2008/05/28/radmind_server_logging_and_the_repo_command</id>
    <published>2008-05-28T20:13:35-05:00</published>
    <updated>2008-05-28T20:20:06-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Tiger" />
    <category term="Computing" />
    <category term="Exploration" />
    <category term="Linux" />
    <category term="Mac OS X" />
    <category term="Open source" />
    <category term="Python" />
    <category term="Radmind" />
    <category term="Shell" />
    <category term="Software" />
    <category term="System administration" />
    <category term="UNIX" />
    <category term="Leopard" />
    <category term="Logging" />
    <category term="Privacy" />
    <category term="Security" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>Under normal circumstances, the latest Radmind tools that communicate with the server report client status updates in the Radmind server&rsquo;s system log. These standard messages can include ones like:<br />
<code>May  8 03:14:56 RadmindServerHost radmind[7890]: report radmind-client.example.com 192.168.7.42 - - ktcheck No updates needed<br />
May 15 03:15:25 RadmindServerHost radmind[24531]: report radmind-client.example.com 192.168.7.42 - - ktcheck Updates retrieved<br />
May 15 03:21:48 RadmindServerHost radmind[24534]: report radmind-client.example.com 192.168.7.42 - - lapply Changes applied successfully<br />
May 15 03:31:07 RadmindServerHost radmind[24356]: report radmind-client.example.com 192.168.7.42 CertificateCN - lapply Error, changes made</code><br />
The Radmind <code>repo</code>, or &ldquo;report,&rdquo; tool provides the ability to send arbitrary messages to the Radmind server process. But how are these messages formatted and sent?<br />
<code>$ <strong>repo -e "Debug" -h radmindserverhost.example.com -w2 "Test message"</strong></code><br />
&#8230; results in the system log message:<br />
<code>May 15 03:31:56 RadmindServerHost radmind[25236]: report radmind-client.example.com 192.168.7.42 CertificateCN - Debug Test message</code><br />
Here, we can see that an entry created with <code>repo</code> looks like the standard Radmind log messages above. The client <em>hostname</em> and <em>IP address</em> are reported after the &ldquo;report&rdquo; text. The <em>CertificateCN</em> for the client &mdash; if the highest authorization level is specified (with the -w2 flag) &mdash; is also listed; if not, a dash takes its place. I haven&rsquo;t seen a case where the second dash is substituted, however.<br />
Finally, where the Radmind command/tool used would normally be, the &ldquo;event&rdquo; specified by <code>repo</code> will printed. After that, the message text appears.<br />
The value proposition is that if you&rsquo;re using Radmind, the <code>repo</code> command can help you send arbitrary messages to the server for logging. As bonus, if you've taken the time and effort to build the certificate infrastructure for Radmind, you can send these messages securely between the clients and the server cloaked in SSL.<br />
If you&rsquo;re using multiple servers, you may want to combine their logs in one location so that you can get all of the clients&rsquo; reports in one location. You may also want or need to retain these reports for more time. In either case, determine what policies you should apply to the syslog or Apple System Logger (ASL, for Mac OS X) configuration for your server systems.<br />
Whether or not you use <code>repo</code>, it&rsquo;s good to know that the tools do some logging. The logging can be followed to try to determine the status of your clients, or whether they are failing their updates.<br />
Unfortunately, the most common client failures I have seen tend to involve the <code>lapply</code> tool, and the default level of detail I&rsquo;ve seen reported back to the server does <em>not</em> provide an indication of what problem has been encountered. You see only that there <em>was</em> an error. Still, even though you may not get enough detail to remotely resolve the problem, it&rsquo;s something for you to go by <em>find</em> problems in the first place.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>Under normal circumstances, the latest Radmind tools that communicate with the server report client status updates in the Radmind server&rsquo;s system log. These standard messages can include ones like:</p>
<p><code>May  8 03:14:56 RadmindServerHost radmind[7890]: report radmind-client.example.com 192.168.7.42 - - ktcheck No updates needed<br />
May 15 03:15:25 RadmindServerHost radmind[24531]: report radmind-client.example.com 192.168.7.42 - - ktcheck Updates retrieved<br />
May 15 03:21:48 RadmindServerHost radmind[24534]: report radmind-client.example.com 192.168.7.42 - - lapply Changes applied successfully<br />
May 15 03:31:07 RadmindServerHost radmind[24356]: report radmind-client.example.com 192.168.7.42 CertificateCN - lapply Error, changes made</code></p>
<p>The Radmind <code>repo</code>, or &ldquo;report,&rdquo; tool provides the ability to send arbitrary messages to the Radmind server process. But how are these messages formatted and sent?</p>
<p><code>$ <strong>repo -e "Debug" -h radmindserverhost.example.com -w2 "Test message"</strong></code></p>
<p>&#8230; results in the system log message:</p>
<p><code>May 15 03:31:56 RadmindServerHost radmind[25236]: report radmind-client.example.com 192.168.7.42 CertificateCN - Debug Test message</code></p>
<p>Here, we can see that an entry created with <code>repo</code> looks like the standard Radmind log messages above. The client <em>hostname</em> and <em>IP address</em> are reported after the &ldquo;report&rdquo; text. The <em>CertificateCN</em> for the client &mdash; if the highest authorization level is specified (with the -w2 flag) &mdash; is also listed; if not, a dash takes its place. I haven&rsquo;t seen a case where the second dash is substituted, however.</p>
<p>Finally, where the Radmind command/tool used would normally be, the &ldquo;event&rdquo; specified by <code>repo</code> will printed. After that, the message text appears.</p>
<p>The value proposition is that if you&rsquo;re using Radmind, the <code>repo</code> command can help you send arbitrary messages to the server for logging. As bonus, if you've taken the time and effort to build the certificate infrastructure for Radmind, you can send these messages securely between the clients and the server cloaked in SSL.</p>
<p>If you&rsquo;re using multiple servers, you may want to combine their logs in one location so that you can get all of the clients&rsquo; reports in one location. You may also want or need to retain these reports for more time. In either case, determine what policies you should apply to the syslog or Apple System Logger (ASL, for Mac OS X) configuration for your server systems.</p>
<p>Whether or not you use <code>repo</code>, it&rsquo;s good to know that the tools do some logging. The logging can be followed to try to determine the status of your clients, or whether they are failing their updates.</p>
<p>Unfortunately, the most common client failures I have seen tend to involve the <code>lapply</code> tool, and the default level of detail I&rsquo;ve seen reported back to the server does <em>not</em> provide an indication of what problem has been encountered. You see only that there <em>was</em> an error. Still, even though you may not get enough detail to remotely resolve the problem, it&rsquo;s something for you to go by <em>find</em> problems in the first place.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Format numbers with the Python locale module</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/05/26/format_numbers_with_the_python_locale_module" />
    <id>http://www.jaharmi.com/2008/05/26/format_numbers_with_the_python_locale_module</id>
    <published>2008-05-26T22:00:09-05:00</published>
    <updated>2008-05-27T14:20:23-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Learning" />
    <category term="Apple" />
    <category term="Computing" />
    <category term="Discovery" />
    <category term="Exploration" />
    <category term="Mac OS X" />
    <category term="Open source" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Software" />
    <category term="System administration" />
    <category term="Leopard" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>I&rsquo;m constantly astounded by the breadth of features available in the Python Standard Library. Although the functions I find there are not always easy to grasp, it is almost always worth searching around a bit for a function or method in the standard library before I write my own code to do something someone else has probably had to do before.<br />
Take the &ldquo;locale&rdquo; module. It lets you format certain kinds of data based on your locale and its customs. Numbers (including currency) happen to be one of its specialties. Since I had a need to output long numbers whose digits were grouped with commas &mdash; which makes them easier to read &mdash; and <code>locale.format()</code> does just that. Even better, it&rsquo;s internationalized and formats them for your system&rsquo;s own locale.<br />
<code>&gt;&gt;&gt; <strong>import locale</strong><br />
&gt;&gt;&gt; <strong>a = {'size': 123456789, 'unit': 'bytes'}</strong><br />
&gt;&gt;&gt; <strong>print(locale.format("%(size).2f", a, 1))</strong><br />
123456789.00<br />
&gt;&gt;&gt; <strong>locale.setlocale(locale.LC_ALL, '')</strong> <em># Set the locale for your system</em><br />
'en_US.UTF-8'<br />
&gt;&gt;&gt; <strong>print(locale.format("%(size).2f", a, 1))</strong><br />
123,456,789.00</code><br />
In trying to use it in the bundled Python 2.5.1 on Mac OS X Leopard, I noticed that the default for scripts and the interpreter doesn&rsquo;t format numbers as I expected for my locale. I found that I needed to <em>set</em> a locale to get the expected formatting. To do this, I run <code>locale.setlocale()</code>, as above. I&rsquo;m not sure if this is required for other Python installations, but it&rsquo;s worth mentioning.<br />
One difficulty I created for myself was when I tried mixing more into my format string. For example, <code>locale.format()</code> would fail to reformat a number when I added in the string for the unit from my original dictionary:<br />
<code>&gt;&gt;&gt; <strong>print(locale.format("%(size).2f %(unit)s", a, 1))</strong><br />
123456789.00 bytes</code><br />
In retrospect, this makes total sense, but it took <a class="freelinking external" href="http://www.facebook.com/profile.php?id=780088555&amp;hiq=chast%2Cmark">Mark</a> looking over my code to discover my error.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I&rsquo;m constantly astounded by the breadth of features available in the Python Standard Library. Although the functions I find there are not always easy to grasp, it is almost always worth searching around a bit for a function or method in the standard library before I write my own code to do something someone else has probably had to do before.</p>
<p>Take the &ldquo;locale&rdquo; module. It lets you format certain kinds of data based on your locale and its customs. Numbers (including currency) happen to be one of its specialties. Since I had a need to output long numbers whose digits were grouped with commas &mdash; which makes them easier to read &mdash; and <code>locale.format()</code> does just that. Even better, it&rsquo;s internationalized and formats them for your system&rsquo;s own locale.</p>
<p><code>&gt;&gt;&gt; <strong>import locale</strong><br />
&gt;&gt;&gt; <strong>a = {'size': 123456789, 'unit': 'bytes'}</strong><br />
&gt;&gt;&gt; <strong>print(locale.format("%(size).2f", a, 1))</strong><br />
123456789.00<br />
&gt;&gt;&gt; <strong>locale.setlocale(locale.LC_ALL, '')</strong> <em># Set the locale for your system</em><br />
'en_US.UTF-8'<br />
&gt;&gt;&gt; <strong>print(locale.format("%(size).2f", a, 1))</strong><br />
123,456,789.00</code></p>
<p>In trying to use it in the bundled Python 2.5.1 on Mac OS X Leopard, I noticed that the default for scripts and the interpreter doesn&rsquo;t format numbers as I expected for my locale. I found that I needed to <em>set</em> a locale to get the expected formatting. To do this, I run <code>locale.setlocale()</code>, as above. I&rsquo;m not sure if this is required for other Python installations, but it&rsquo;s worth mentioning.</p>
<p>One difficulty I created for myself was when I tried mixing more into my format string. For example, <code>locale.format()</code> would fail to reformat a number when I added in the string for the unit from my original dictionary:</p>
<p><code>&gt;&gt;&gt; <strong>print(locale.format("%(size).2f %(unit)s", a, 1))</strong><br />
123456789.00 bytes</code></p>
<p>In retrospect, this makes total sense, but it took <a class="freelinking external" href="http://www.facebook.com/profile.php?id=780088555&amp;hiq=chast%2Cmark">Mark</a> looking over my code to discover my error.</p>
    ]]></content>
  </entry>
  <entry>
    <title>Python string method for title case, versus the Daring Fireball script</title>
    <link rel="alternate" type="text/html" href="http://www.jaharmi.com/2008/05/20/python_string_method_for_title_case_versus_the_daring_fireball_script" />
    <id>http://www.jaharmi.com/2008/05/20/python_string_method_for_title_case_versus_the_daring_fireball_script</id>
    <published>2008-05-20T15:55:31-05:00</published>
    <updated>2008-05-20T15:55:36-05:00</updated>
    <author>
      <name>Jaharmi</name>
    </author>
    <category term="Computing" />
    <category term="Humor" />
    <category term="Open source" />
    <category term="Perl" />
    <category term="Python" />
    <category term="Scripting" />
    <category term="Shell" />
    <category term="Software" />
    <category term="Leopard" />
    <category term="Suppliers" />
    <category term="Technology" />
    <summary type="html"><![CDATA[<p>I ran a quick test of the Python &ldquo;title&rdquo; string method (from Python 2.5.1 in Leopard); it fails the tests on the edge cases mentioned in the <a class="freelinking external" href="http://daringfireball.net/2008/05/title_case">Title Case</a> post at Daring Fireball. It really only uppercases the first letter of every word and lowercases everything else.<br />
Not much better than looping through a string with ucfirst() in Perl, except you don't have to do the looping yourself.<br />
Drat. I was expecting better.</p>
    ]]></summary>
    <content type="html"><![CDATA[<p>I ran a quick test of the Python &ldquo;title&rdquo; string method (from Python 2.5.1 in Leopard); it fails the tests on the edge cases mentioned in the <a class="freelinking external" href="http://daringfireball.net/2008/05/title_case">Title Case</a> post at Daring Fireball. It really only uppercases the first letter of every word and lowercases everything else.</p>
<p>Not much better than looping through a string with ucfirst() in Perl, except you don't have to do the looping yourself.</p>
<p>Drat. I was expecting better.</p>
    ]]></content>
  </entry>
</feed>
