<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Comments &#187; Python</title>
	<atom:link href="http://code.hammerpig.com/category/python/feed" rel="self" type="application/rss+xml" />
	<link>http://code.hammerpig.com</link>
	<description>Tips and short tutorials on various programming technologies</description>
	<lastBuildDate>Fri, 23 Dec 2011 23:09:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Delete Files Using Python Code</title>
		<link>http://code.hammerpig.com/delete-files-python.html</link>
		<comments>http://code.hammerpig.com/delete-files-python.html#comments</comments>
		<pubDate>Fri, 23 Dec 2011 23:09:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=730</guid>
		<description><![CDATA[It&#8217;s really easy to delete a single file in Python. Say the file you want to delete is called &#8220;MyFile.txt.&#8221; You could delete it using this syntax:

import os
&#160;
os.remove&#40;&#34;MyFile.txt&#34;&#41;

Let&#8217;s say you had many files in a directory, and the ones you wanted to delete were called MyFile1.txt, MyFile2.txt, and MyFile3.txt. One trick that you can use [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/delete-files-python.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorting String Values That Contain Numbers in Python</title>
		<link>http://code.hammerpig.com/sorting-string-values-numbers-python.html</link>
		<comments>http://code.hammerpig.com/sorting-string-values-numbers-python.html#comments</comments>
		<pubDate>Tue, 07 Jun 2011 22:49:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=680</guid>
		<description><![CDATA[If you have a list of String objects in Python and want to sort them but treat any numeric values accordingly, it will not work with the regular sort function in Python. So if you have the following list:

x = &#91;&#34;3&#34;, &#34;1&#34;, &#34;10&#34;, &#34;2&#34;&#93;

You will get the following if you sort and print it:

print sorted&#40;x&#41; [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/sorting-string-values-numbers-python.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fast Way to Filter Large Python Lists</title>
		<link>http://code.hammerpig.com/fast-filter-large-python-lists.html</link>
		<comments>http://code.hammerpig.com/fast-filter-large-python-lists.html#comments</comments>
		<pubDate>Wed, 09 Mar 2011 21:53:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=670</guid>
		<description><![CDATA[Let&#8217;s say you have a list of Python objects.

x = &#91;&#91;&#34;1&#34;,&#34;a&#34;&#93;, &#91;&#34;2&#34;, &#34;a&#34;&#93;, &#91;&#34;3&#34;,&#34;b&#34;&#93;, &#91;&#34;4&#34;,&#34;c&#34;&#93;&#93;

And you have a second list of Python objects.

y = &#91;&#34;a&#34;, &#34;b&#34;&#93;

Now let&#8217;s say you want to filter x so that it only contains objects for which the second value corresponds to the values in y. So in this case you [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/fast-filter-large-python-lists.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Dynamically Invoke a Function in Python</title>
		<link>http://code.hammerpig.com/dynamically-invoke-function-python.html</link>
		<comments>http://code.hammerpig.com/dynamically-invoke-function-python.html#comments</comments>
		<pubDate>Thu, 25 Mar 2010 16:56:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Reflection]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=624</guid>
		<description><![CDATA[In this post, I referred to an article that explains how to invoke methods dynamically (when you have the name of the method as a string object). Today I ran into a problem where I needed to do this, but the methods were not contained within a class. I just had them declared in my [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/dynamically-invoke-function-python.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get File Name from File Path in Python</title>
		<link>http://code.hammerpig.com/file-file-path-python-2.html</link>
		<comments>http://code.hammerpig.com/file-file-path-python-2.html#comments</comments>
		<pubDate>Thu, 03 Dec 2009 16:53:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/file-file-path-python-2.html</guid>
		<description><![CDATA[Let&#8217;s say you did a search for files matching a certain pattern in a directory using Python:

import glob
&#160;
filePaths = glob.glob&#40;&#34;C:\\Temp\\*.txt&#34;&#41;
print filePaths

This will list the full file paths with a .txt extension in the C:\Temp directory. For example: C:\\Temp\\test.txt.
But if you wanted to get just the file name, how would you go about that? It took [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/file-file-path-python-2.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Minimum or Maximum Float Value in Python 2.5</title>
		<link>http://code.hammerpig.com/minimum-maximum-float-python-25.html</link>
		<comments>http://code.hammerpig.com/minimum-maximum-float-python-25.html#comments</comments>
		<pubDate>Wed, 08 Jul 2009 20:09:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=549</guid>
		<description><![CDATA[In Python 2.5, there is a built-in function that tells you the maximum allowable int value:

import sys
print sys.maxint

But there is no corresponding function to do this for float values. Part of the reason may be that it can vary from system to system. But actually, I believe they added this in version 2.6. So this [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/minimum-maximum-float-python-25.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to List All Methods in a Python Object</title>
		<link>http://code.hammerpig.com/list-methods-python-object.html</link>
		<comments>http://code.hammerpig.com/list-methods-python-object.html#comments</comments>
		<pubDate>Wed, 17 Jun 2009 20:11:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Reflection]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=543</guid>
		<description><![CDATA[Suppose you have an object in Python that you retrieved from a third-party library, but you don&#8217;t have access to the source code or to very good documentation. Believe me, it happens (and did to me today). You can use a simple built-in method in Python to find out which methods are exposed by a [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/list-methods-python-object.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Invoke External Application in Java</title>
		<link>http://code.hammerpig.com/invoke-external-application-java.html</link>
		<comments>http://code.hammerpig.com/invoke-external-application-java.html#comments</comments>
		<pubDate>Thu, 04 Jun 2009 22:27:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tip]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=541</guid>
		<description><![CDATA[I recently had a scenario where part of what I wanted to do was in Java, and the other part was in an application that was written in Python. Rather than than rewrite my entire code base in one language or the other, I wanted to find a (quick and dirty) way to invoke the [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/invoke-external-application-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Last Index Of&#8221; for Python Strings</title>
		<link>http://code.hammerpig.com/index-python-strings.html</link>
		<comments>http://code.hammerpig.com/index-python-strings.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 21:38:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=539</guid>
		<description><![CDATA[In Java and C#, there is a method that enables you to find the last occurrence of a given sequence of string characters within a string. This method is sometimes called &#8220;lastIndexOf.&#8221; A method by this name does not exist in Python. But there is an easy way to do it if you know what [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/index-python-strings.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Reverse Sequence of Numbers in Python</title>
		<link>http://code.hammerpig.com/creating-reverse-sequence-numbers-python.html</link>
		<comments>http://code.hammerpig.com/creating-reverse-sequence-numbers-python.html#comments</comments>
		<pubDate>Wed, 14 Jan 2009 15:15:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Collections]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://code.hammerpig.com/?p=529</guid>
		<description><![CDATA[Let&#8217;s say you want to create a sequence of numbers in reverse order (for example, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1). I tried to do this with the range function, but I couldn&#8217;t find a way to do it. But Python has a built-in function called reversed that allows you to [...]]]></description>
		<wfw:commentRss>http://code.hammerpig.com/creating-reverse-sequence-numbers-python.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

