<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python Quirks in Cmd, urllib2, and decorators</title>
	<atom:link href="http://www.protocolostomy.com/2009/10/28/python-quirks-in-cmd-urllib2-and-decorators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.protocolostomy.com/2009/10/28/python-quirks-in-cmd-urllib2-and-decorators/</link>
	<description>Made with only the finest 1's and 0's</description>
	<lastBuildDate>Fri, 03 Sep 2010 11:21:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: srid</title>
		<link>http://www.protocolostomy.com/2009/10/28/python-quirks-in-cmd-urllib2-and-decorators/comment-page-1/#comment-27189</link>
		<dc:creator>srid</dc:creator>
		<pubDate>Sat, 07 Nov 2009 14:42:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=633#comment-27189</guid>
		<description>cmdln is a Python library that does what Cmd and optparser combined .. misses. http://code.google.com/p/cmdln</description>
		<content:encoded><![CDATA[<p>cmdln is a Python library that does what Cmd and optparser combined .. misses. <a href="http://code.google.com/p/cmdln" rel="nofollow">http://code.google.com/p/cmdln</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: m0j0</title>
		<link>http://www.protocolostomy.com/2009/10/28/python-quirks-in-cmd-urllib2-and-decorators/comment-page-1/#comment-26397</link>
		<dc:creator>m0j0</dc:creator>
		<pubDate>Thu, 29 Oct 2009 12:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=633#comment-26397</guid>
		<description>Thanks for this -- I haven&#039;t actually implemented this in my code yet, so nice to know in advance, though I did expect that to some degree I was still going to have to restrict the user in some way to make parsing the args line predictable. 

Another option I forgot to mention that either a) alleviates the issue or b) trades one problem for another is to use raw_input, which Cmd will handle in a sane way. That&#039;s actually what I&#039;m using for my &#039;connect&#039; method now. I imported getpass to handle the password :)</description>
		<content:encoded><![CDATA[<p>Thanks for this &#8212; I haven&#8217;t actually implemented this in my code yet, so nice to know in advance, though I did expect that to some degree I was still going to have to restrict the user in some way to make parsing the args line predictable. </p>
<p>Another option I forgot to mention that either a) alleviates the issue or b) trades one problem for another is to use raw_input, which Cmd will handle in a sane way. That&#8217;s actually what I&#8217;m using for my &#8216;connect&#8217; method now. I imported getpass to handle the password <img src='http://www.protocolostomy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: j_king</title>
		<link>http://www.protocolostomy.com/2009/10/28/python-quirks-in-cmd-urllib2-and-decorators/comment-page-1/#comment-26396</link>
		<dc:creator>j_king</dc:creator>
		<pubDate>Thu, 29 Oct 2009 12:34:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=633#comment-26396</guid>
		<description>Roger is right, you should be using the shlex module. The unicode issue is kind of annoying but can be abstracted away.

Decorators are really simple but I think the trip up is that people expect them to be complex. Just gotta remember that they&#039;re only syntactic sugar. Instead of always calling f(x()) you can just use the decorator syntax. They&#039;re the same thing.

You can get more complex than that, but the beginning Python programmer doesn&#039;t need to worry about it; they&#039;re pretty far edge cases that a programmer should have enough experience with Python to not be phased by it when they come across it.</description>
		<content:encoded><![CDATA[<p>Roger is right, you should be using the shlex module. The unicode issue is kind of annoying but can be abstracted away.</p>
<p>Decorators are really simple but I think the trip up is that people expect them to be complex. Just gotta remember that they&#8217;re only syntactic sugar. Instead of always calling f(x()) you can just use the decorator syntax. They&#8217;re the same thing.</p>
<p>You can get more complex than that, but the beginning Python programmer doesn&#8217;t need to worry about it; they&#8217;re pretty far edge cases that a programmer should have enough experience with Python to not be phased by it when they come across it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger</title>
		<link>http://www.protocolostomy.com/2009/10/28/python-quirks-in-cmd-urllib2-and-decorators/comment-page-1/#comment-26362</link>
		<dc:creator>Roger</dc:creator>
		<pubDate>Thu, 29 Oct 2009 04:28:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=633#comment-26362</guid>
		<description>As you point out the interesting part is splitting the string into pieces.  Using regular split is a bad idea since it won&#039;t cope with quoted arguments.

Instead you can use shlex.split which does the job really well.  It has two gotchas.  The first is that it doesn&#039;t process backslashes. so if someone did --password=abc\ def then you&#039;ll still get that literally - ie you&#039;ll need to turn backslash space in to a space, t into tab, quote into a quote etc.

The second problem is that shlex.split is completely broken in Python 2 (Py 3 is ok) if you supply a Unicode string.  It works on the raw Unicode binary bytes giving a resulting mess.  If you are using unicode (which you should) then you have to convert to utf8 first, call it and then convert the results back to Unicode.</description>
		<content:encoded><![CDATA[<p>As you point out the interesting part is splitting the string into pieces.  Using regular split is a bad idea since it won&#8217;t cope with quoted arguments.</p>
<p>Instead you can use shlex.split which does the job really well.  It has two gotchas.  The first is that it doesn&#8217;t process backslashes. so if someone did &#8211;password=abc\ def then you&#8217;ll still get that literally &#8211; ie you&#8217;ll need to turn backslash space in to a space, t into tab, quote into a quote etc.</p>
<p>The second problem is that shlex.split is completely broken in Python 2 (Py 3 is ok) if you supply a Unicode string.  It works on the raw Unicode binary bytes giving a resulting mess.  If you are using unicode (which you should) then you have to convert to utf8 first, call it and then convert the results back to Unicode.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
