<?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>Big Bad Code &#187; python</title>
	<atom:link href="http://bigbadcode.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigbadcode.com</link>
	<description>Don't blame me, I voted for Kodos</description>
	<lastBuildDate>Wed, 19 Aug 2009 21:49:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Networked Sound Board</title>
		<link>http://bigbadcode.com/2009/01/24/networked-sound-board/</link>
		<comments>http://bigbadcode.com/2009/01/24/networked-sound-board/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 03:59:35 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[flex code python git github]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/?p=222</guid>
		<description><![CDATA[Super fun networked sound board for use any place you have multiple people with computers and a central computer with speakers everyone can hear. ]]></description>
			<content:encoded><![CDATA[<p>Hi Everybody,</p>
<p>I&#8217;ve created a network sound board that you can use to have endless fun with co-workers.</p>
<p>In my office quad we have one OSX machine that is used to play music for everyone, it&#8217;s usually running last.fm, pandora or someones iTunes library as background music for everyone. Occasionally it gets cranked up when it&#8217;s time to get the <a href="http://www.ledzeppelin.com/" target="_blank">led</a> out. I was thinking that it&#8217;d be fun to be able to trigger sound effects on that machine from my machine, kind of like what happens on radio shows, expect that my co-workers wouldn&#8217;t really be able to change the channel.</p>
<p>So the itch was scratched and I&#8217;m proud to present the network sound board. It should run out of the box on any OSX machine with a recent installation of Python. If you&#8217;re on Windows or Linux it&#8217;ll work if you can find a command line audio player.  Anybody on the same network as the music machine will be able to trigger the sound effects from the comfort of their browsers. After you install there is a soundEffects folder that you can place sound files (.wav/mp3) into and they are instantly available, check the documentation for more info.</p>
<p><a href="http://github.com/code128/networkedsoundboard/tree/master">You can git the source from github at http://github.com/code128/networkedsoundboard/tree/master<br />
</a></p>
<p>It looks like this.</p>
<p><a href="http://bigbadcode.com/wp-content/uploads/2009/01/2009-01-24_1632.png"><img class="alignnone size-medium wp-image-224" title="networked_soundboard" src="http://bigbadcode.com/wp-content/uploads/2009/01/2009-01-24_1632-295x300.png" alt="networked_soundboard" width="295" height="300" /></a></p>
<p>If you&#8217;re looking to extend it, adding the ability to upload new sounds from the flex interface would be sweet. If you do let me know.</p>
<p>Have fun.</p>
<p>P.S. If you can get samples of your co-workers saying things and add them to the server that would just be the icing on the comedy cake.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2009/01/24/networked-sound-board/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iterating over a custom object in python</title>
		<link>http://bigbadcode.com/2008/10/22/iterating-over-a-custom-object-in-python/</link>
		<comments>http://bigbadcode.com/2008/10/22/iterating-over-a-custom-object-in-python/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 17:18:55 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/?p=204</guid>
		<description><![CDATA[A coworker recently needed to iterate over a custom object in python. It&#8217;s pretty easy to do, you just need to implement the __iter__ method on your object. 
Here&#8217;s some example code that shows you how to extend your object, returning everything in your objects local dictionary:

class IterableObject&#40;object&#41;:
    def __iter__&#40;self&#41;:
   [...]]]></description>
			<content:encoded><![CDATA[<p>A coworker recently needed to iterate over a custom object in python. It&#8217;s pretty easy to do, you just need to implement the __iter__ method on your object. </p>
<p>Here&#8217;s some example code that shows you how to extend your object, returning everything in your objects local dictionary:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> IterableObject<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__iter__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: #0000cd;">__dict__</span>:
            <span style="color: #ff7700;font-weight:bold;">yield</span> <span style="color: #008000;">self</span>.<span style="color: #0000cd;">__dict__</span><span style="color: black;">&#91;</span>item<span style="color: black;">&#93;</span></pre></div></div>

<p>Now for sample usage:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;">myObj = IterableObject<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
myObj.<span style="color: black;">name</span> = <span style="color: #483d8b;">&quot;Johnny Hammersticks&quot;</span>
myObj.<span style="color: black;">otherProperty</span> = <span style="color: #483d8b;">&quot;Something Else&quot;</span>
myObj.<span style="color: black;">testList</span> = <span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">2</span>,<span style="color: #ff4500;">3</span>,<span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>
myObj.<span style="color: black;">testDict</span> = <span style="color: black;">&#123;</span><span style="color: #ff4500;">1</span>:<span style="color: #483d8b;">'one'</span>, <span style="color: #ff4500;">2</span>:<span style="color: #483d8b;">'two'</span><span style="color: black;">&#125;</span>
<span style="color: #808080; font-style: italic;"># Serialize the IterableObject into json</span>
<span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> myObj:
     <span style="color: #ff7700;font-weight:bold;">print</span> x, <span style="color: #008000;">type</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span></pre></div></div>

<p>which returns:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;">Something Else <span style="color: #66cc66;">&lt;</span>type <span style="color: #483d8b;">'str'</span><span style="color: #66cc66;">&gt;</span>
<span style="color: black;">&#123;</span><span style="color: #ff4500;">1</span>: <span style="color: #483d8b;">'one'</span>, <span style="color: #ff4500;">2</span>: <span style="color: #483d8b;">'two'</span><span style="color: black;">&#125;</span> <span style="color: #66cc66;">&lt;</span>type <span style="color: #483d8b;">'dict'</span><span style="color: #66cc66;">&gt;</span>
<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">&lt;</span>type <span style="color: #483d8b;">'list'</span><span style="color: #66cc66;">&gt;</span>
Johnny Hammersticks <span style="color: #66cc66;">&lt;</span>type <span style="color: #483d8b;">'str'</span><span style="color: #66cc66;">&gt;</span></pre></div></div>

<p>Oh and another handy feature of this dictionary style approach, you can do easy string formatting/printing of the object properties in this style.</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Hi %(name)s, your list %(testList)s&quot;</span> <span style="color: #66cc66;">%</span> myObj.<span style="color: #0000cd;">__dict__</span></pre></div></div>

<p>Which prints:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;">Hi Johnny Hammersticks, your <span style="color: #008000;">list</span>: <span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>, <span style="color: #ff4500;">2</span>, <span style="color: #ff4500;">3</span>, <span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2008/10/22/iterating-over-a-custom-object-in-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FlixBot</title>
		<link>http://bigbadcode.com/2008/10/20/flixbot/</link>
		<comments>http://bigbadcode.com/2008/10/20/flixbot/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 05:59:18 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[netflix]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/?p=192</guid>
		<description><![CDATA[I&#8217;ve built a proof of concept in some hacked together python code to automatically add movies to my netflix queue when I send twitter messages to @flixbot.
For example this tweet:

Gets Blade into my queue. Awesome.
I started building this out into a full fledged service so other people can use it as well. Of course I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve built a proof of concept in some hacked together python code to automatically add movies to my netflix queue when I send twitter messages to @flixbot.</p>
<p>For example this tweet:</p>
<p><a href="http://bigbadcode.com/wp-content/uploads/2008/10/2008-10-20_2241.png"><img class="alignnone size-medium wp-image-194" title="2008-10-20_2241" src="http://bigbadcode.com/wp-content/uploads/2008/10/2008-10-20_2241-300x130.png" alt="" width="300" height="130" /></a></p>
<p>Gets Blade into my queue. Awesome.</p>
<p>I started building this out into a full fledged service so other people can use it as well. Of course I&#8217;m going to need a hosted site somewhere for people to sign up. I figured it might be a good time to play with my app engine account.</p>
<p>I got part of the way of there with app engine serving up pages, but then ran into problems with xml libraries I was using in my POC not existing in the AppEngine sandbox. <img src='http://bigbadcode.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Also I&#8217;m starting to run out of enthusiasm.</p>
<p>So that&#8217;s where I&#8217;m at. Goodnight.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2008/10/20/flixbot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duplicate music file finder code.</title>
		<link>http://bigbadcode.com/2008/01/21/duplicate-music-file-finder-code/</link>
		<comments>http://bigbadcode.com/2008/01/21/duplicate-music-file-finder-code/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 01:11:52 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2008/01/21/duplicate-music-file-finder-code/</guid>
		<description><![CDATA[I&#8217;ve been consolidating my music collection and found that there were lots of duplicate files. 
Most of the dupes were named something like &#8220;Happy Birthday 1.mp3&#8243; and &#8220;Happy Birthday.mp3&#8243; would exist in the same directory. I&#8217;m not sure which program added these dupes, but removing 2500 or so of em by hand would not be [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been consolidating my music collection and found that there were lots of duplicate files. </p>
<p>Most of the dupes were named something like &#8220;Happy Birthday 1.mp3&#8243; and &#8220;Happy Birthday.mp3&#8243; would exist in the same directory. I&#8217;m not sure which program added these dupes, but removing 2500 or so of em by hand would not be fun. </p>
<p>Without further ado, here&#8217;s some python code that takes care of that problem for you. It only examines the filename, not the date or the bitrate or the actual file contents, etc. But you could of course extend it to do all those things. </p>
<p>Enjoy.</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#-------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Name:        cleanDuplicateMusicFiles.py</span>
<span style="color: #808080; font-style: italic;"># Purpose:     Loops over a directory structure looking for 'duplicate' music files</span>
<span style="color: #808080; font-style: italic;">#				and moving them to a safe directory for deletion.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Author:      Joshua Bloom</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Created:     01/18/2008</span>
<span style="color: #808080; font-style: italic;">#-------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
dupList = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
rootDirectory = <span style="color: #483d8b;">&quot;/Users/joshbloom/Music/iTunes/iTunes Music&quot;</span>
sequesteredFilesDirectory = <span style="color: #483d8b;">&quot;/Users/joshbloom&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Starting search ...&quot;</span>
    checkDir<span style="color: black;">&#40;</span>rootDirectory<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Found %s dupes&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>dupList<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> checkDir<span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Checking path '%s' for duplicates&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">basename</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>path, x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">listdir</span><span style="color: black;">&#40;</span>path<span style="color: black;">&#41;</span> <span style="color: black;">&#93;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">isdir</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span>:
            checkDir<span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            checkForDupe<span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> checkForDupe<span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span>:
	<span style="color: #483d8b;">''</span><span style="color: #483d8b;">'Example: if we find '</span>Happy Birthday 1.<span style="color: black;">mp3</span><span style="color: #483d8b;">' and '</span>Happy Birthday.<span style="color: black;">mp3</span><span style="color: #483d8b;">' exists in the
	same directory we consider this a duplicate and send it for re-education. '</span><span style="color: #483d8b;">''</span>
    fileName = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">basename</span><span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span>
    folderList = <span style="color: #dc143c;">os</span>.<span style="color: black;">listdir</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> fileName.<span style="color: black;">endswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;1.mp3&quot;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> otherName <span style="color: #ff7700;font-weight:bold;">in</span> folderList:
            <span style="color: #ff7700;font-weight:bold;">if</span> otherName <span style="color: #66cc66;">!</span>= fileName: <span style="color: #808080; font-style: italic;">#Make sure we aren't comparing with the current file</span>
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">basename</span> <span style="color: black;">&#40;</span>otherName<span style="color: black;">&#41;</span>.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span>fileName<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:
                    <span style="color: #808080; font-style: italic;">#This is a duplicate</span>
                    dupList.<span style="color: black;">append</span><span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span>
                    sequesterDup<span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> sequesterDup<span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">''</span><span style="color: #483d8b;">' Move em to a new folder, if you were confident you could change
 		this function to delete the file. '</span><span style="color: #483d8b;">''</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Moving file: %s&quot;</span> <span style="color: #66cc66;">%</span> fName
        <span style="color: #dc143c;">os</span>.<span style="color: black;">rename</span><span style="color: black;">&#40;</span>fName, <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>sequesteredFilesDirectory, <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">basename</span><span style="color: black;">&#40;</span>fName<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">Exception</span>, E:
        <span style="color: #ff7700;font-weight:bold;">print</span> E
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2008/01/21/duplicate-music-file-finder-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto twitter SMS on/off</title>
		<link>http://bigbadcode.com/2007/07/20/auto-twitter-sms-onoff/</link>
		<comments>http://bigbadcode.com/2007/07/20/auto-twitter-sms-onoff/#comments</comments>
		<pubDate>Sat, 21 Jul 2007 05:13:51 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2007/07/20/auto-twitter-sms-onoff/</guid>
		<description><![CDATA[So I&#8217;ve spent a little more time thinking about this and have decided this utility would be better as a server utility that sits out in the cloud and monitors for my computer activity. If it doesn&#8217;t see activity for some set period it notifies twitter to re-enable SMS messages.
This takes care of any issues [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve spent a little more time thinking about this and have decided this utility would be better as a server utility that sits out in the cloud and monitors for my computer activity. If it doesn&#8217;t see activity for some set period it notifies twitter to re-enable SMS messages.<br />
This takes care of any issues with me shutting down or closing my laptop/computer before my notifier can get its message out.</p>
<p>I&#8217;m thinking a python script, called by cron that checks for an indication that I&#8217;m active on my computer, if it doesn&#8217;t see the indication after some number of tries it turns SMS notifications on. That part seems pretty solid, what should I use on the laptop to signal my presence? If this was a Windows machine I&#8217;d be off and running but I&#8217;ve recently switched to a Mac and I don&#8217;t know the platform very well. Instant messenger sounds like something to tap into as it already has the concept of active/idle built into it, but I&#8217;m using Adium and it seems like Adium plug-ins are written in Objective-C which is totally foreign to me. </p>
<p>I think it&#8217;s time for some googling&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2007/07/20/auto-twitter-sms-onoff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert m4a to mp3</title>
		<link>http://bigbadcode.com/2007/06/06/convert-m4a-to-mp3/</link>
		<comments>http://bigbadcode.com/2007/06/06/convert-m4a-to-mp3/#comments</comments>
		<pubDate>Wed, 06 Jun 2007 14:15:41 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[m4a]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2007/06/06/convert-m4a-to-mp3/</guid>
		<description><![CDATA[I&#8217;ve been moving a bunch of my brothers music out of iTunes for him so he can use it with portable players besides iPod. Unfortunately he encoded a lot of his cd&#8217;s in .m4a format. I found a decent utility for converting to mp3 (and other formats) http://www.bonkenc.org/
Unfortunately when you point Bonk at a directory [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been moving a bunch of my brothers music out of iTunes for him so he can use it with portable players besides iPod. Unfortunately he encoded a lot of his cd&#8217;s in .m4a format. I found a decent <a href="http://www.bonkenc.org/">utility for converting to mp3 (and other formats) http://www.bonkenc.org/</a></p>
<p>Unfortunately when you point Bonk at a directory full of m4a&#8217;s it crashes on certain files for some reason (encoding issues probably.) After the crash you need to setup all of your settings and add the files again, which is really time consuming and annoying.</p>
<p>To make this easier I whipped  up a short python script that calls Bonk for you on each file, if it runs into a bad file it will rename the file for you so you don&#8217;t try to process it again. </p>
<p>Here&#8217;s the python code:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">pprint</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span>
curDir = <span style="color: #dc143c;">os</span>.<span style="color: black;">getcwd</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># The current directory. This should contain your .m4a files</span>
pathToBonk = <span style="color: #483d8b;">&quot;C:<span style="color: #000099; font-weight: bold;">\\</span>Program Files<span style="color: #000099; font-weight: bold;">\\</span>BonkEnc<span style="color: #000099; font-weight: bold;">\\</span>becmd.exe&quot;</span> <span style="color: #808080; font-style: italic;">#Where the becmd.exe file lives</span>
problemFiles = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;">#A list of files that failed conversion</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">listdir</span><span style="color: black;">&#40;</span>curDir<span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">if</span> item.<span style="color: black;">upper</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">endswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'.M4A'</span><span style="color: black;">&#41;</span>:
		fullPath = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>curDir,item<span style="color: black;">&#41;</span>
		<span style="color: #dc143c;">cmd</span> = <span style="color: #483d8b;">'&quot;%s&quot; -e LAME -d &quot;%s&quot; &quot;%s&quot;'</span> <span style="color: #808080; font-style: italic;">#The command to convert a single file</span>
		<span style="color: #dc143c;">cmd</span> = <span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>pathToBonk, curDir, fullPath<span style="color: black;">&#41;</span>
		val = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">call</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> val == 0: <span style="color: #808080; font-style: italic;">#Successfull conversion, delete the original</span>
			<span style="color: #dc143c;">os</span>.<span style="color: black;">remove</span><span style="color: black;">&#40;</span>fullPath<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			problemFiles.<span style="color: black;">append</span><span style="color: black;">&#40;</span>fullPath<span style="color: black;">&#41;</span>
			<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Problem converting %s'</span> <span style="color: #66cc66;">%</span> item
			<span style="color: #dc143c;">os</span>.<span style="color: black;">rename</span><span style="color: black;">&#40;</span>fullPath, fullPath + <span style="color: #483d8b;">&quot;.BAD&quot;</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'These files had problems converting and have been renamed with .BAD extensions:'</span>
<span style="color: #dc143c;">pprint</span>.<span style="color: #dc143c;">pprint</span><span style="color: black;">&#40;</span>problemFiles<span style="color: black;">&#41;</span></pre></div></div>

<p>NOTES: This will <strong>delete </strong>the .m4a file after converting it. If you want to keep your old files for some reason make sure to run this on a copy of your files. IE in a different directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2007/06/06/convert-m4a-to-mp3/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Count the duplicates in a Python List</title>
		<link>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/</link>
		<comments>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 20:33:13 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/</guid>
		<description><![CDATA[Here&#8217;s a nice little function I&#8217;ve written to report the number of duplicates in a python list.

from sets import Set
#
def countDuplicatesInList&#40;dupedList&#41;:
   uniqueSet = Set&#40;item for item in dupedList&#41;
   return &#91;&#40;item, dupedList.count&#40;item&#41;&#41; for item in uniqueSet&#93;
#
lst = &#91;'I1','I2','I1','I3','I4','I4','I7','I7','I7','I7','I7'&#93;
print countDuplicatesInList&#40;lst&#41;

The Set datatype is an unordered set that doesn&#8217;t allow duplicates, so the first [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a nice little function I&#8217;ve written to report the number of duplicates in a python list.</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">sets</span> <span style="color: #ff7700;font-weight:bold;">import</span> Set
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #ff7700;font-weight:bold;">def</span> countDuplicatesInList<span style="color: black;">&#40;</span>dupedList<span style="color: black;">&#41;</span>:
   uniqueSet = Set<span style="color: black;">&#40;</span>item <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> dupedList<span style="color: black;">&#41;</span>
   <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>item, dupedList.<span style="color: black;">count</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> uniqueSet<span style="color: black;">&#93;</span>
<span style="color: #808080; font-style: italic;">#</span>
lst = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'I1'</span>,<span style="color: #483d8b;">'I2'</span>,<span style="color: #483d8b;">'I1'</span>,<span style="color: #483d8b;">'I3'</span>,<span style="color: #483d8b;">'I4'</span>,<span style="color: #483d8b;">'I4'</span>,<span style="color: #483d8b;">'I7'</span>,<span style="color: #483d8b;">'I7'</span>,<span style="color: #483d8b;">'I7'</span>,<span style="color: #483d8b;">'I7'</span>,<span style="color: #483d8b;">'I7'</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> countDuplicatesInList<span style="color: black;">&#40;</span>lst<span style="color: black;">&#41;</span></pre></div></div>

<p>The Set datatype is an unordered set that doesn&#8217;t allow duplicates, so the first line in the function adds each item in the original list to the Set. The set automatically throws out duplicates so we end up with a unique list.<br />
The next line creates a tuple of the unique item name and its count in the original list.</p>
<p>The output of the function will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'I1'</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #483d8b;">'I3'</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #483d8b;">'I2'</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #483d8b;">'I4'</span>, <span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span><span style="color: #483d8b;">'I7'</span>, <span style="color: #ff4500;">5</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Million Monkeys making Shakespeare?</title>
		<link>http://bigbadcode.com/2007/02/14/a-million-monkeys-making-shakespeare/</link>
		<comments>http://bigbadcode.com/2007/02/14/a-million-monkeys-making-shakespeare/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 01:06:48 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2007/02/14/a-million-monkeys-making-shakespeare/</guid>
		<description><![CDATA[So I had a little time on my hands and thought it might be fun to get to the bottom of this Infinite Monkeys and Shakespeare dillema.
Here&#8217;s some python code that tries to randomly write the line &#8220;Alas, poor Yorick, I knew him, Horatio.&#8221; To make it easier I&#8217;ve ignored punctuation and case but still, [...]]]></description>
			<content:encoded><![CDATA[<p>So I had a little time on my hands and thought it might be fun to get to the bottom of this Infinite Monkeys and Shakespeare dillema.</p>
<p>Here&#8217;s some python code that tries to randomly write the line &#8220;Alas, poor Yorick, I knew him, Horatio.&#8221; To make it easier I&#8217;ve ignored punctuation and case but still, you&#8217;re gonna need a lot of monkeys to get this level of randomness to happen.</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#-------------------------------------------------------------------------------</span>
<span style="color: #808080; font-style: italic;"># Name:        CreateShakespeare.py</span>
<span style="color: #808080; font-style: italic;"># Purpose:     Simulate lots of monkeys banging on typewriters. Find out how long</span>
<span style="color: #808080; font-style: italic;">#               it takes to create shakespeare. To make it easy we just want our</span>
<span style="color: #808080; font-style: italic;">#               monkeys to write the line</span>
<span style="color: #808080; font-style: italic;">#               &quot;Alas, poor Yorick, I knew him, Horatio&quot;</span>
<span style="color: #808080; font-style: italic;">#               And we'll ignore the punctuation and case to make it easier for</span>
<span style="color: #808080; font-style: italic;">#               our tireless computer monkeys.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Author:      jbloom</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Created:     07/11/2006</span>
<span style="color: #808080; font-style: italic;">#-------------------------------------------------------------------------------</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">string</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span>
&nbsp;
correctText = <span style="color: #483d8b;">'Alas poor Yorick I knew him Horatio'</span>
charList = <span style="color: #dc143c;">string</span>.<span style="color: black;">ascii_uppercase</span> + <span style="color: #483d8b;">' '</span>
startTime = <span style="color: #dc143c;">time</span>.<span style="color: black;">localtime</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
endTime = <span style="color: #008000;">None</span>
currentLoopCounter = 0
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getRandomCharacter<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> charList<span style="color: black;">&#91;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">randrange</span><span style="color: black;">&#40;</span>0,<span style="color: #ff4500;">27</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> createRandomLine<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
   <span style="color: #483d8b;">''</span><span style="color: #483d8b;">'Creates the Random Line by monkey power'</span><span style="color: #483d8b;">''</span>
   randomLine = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
   <span style="color: #ff7700;font-weight:bold;">for</span> char <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>correctText<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
   randomLine.<span style="color: black;">append</span><span style="color: black;">&#40;</span>getRandomCharacter<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
   <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>randomLine<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> testLine<span style="color: black;">&#40;</span>inputLine<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">''</span><span style="color: #483d8b;">'Tests the passed line to see if we got the correct text '</span><span style="color: #483d8b;">''</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> inputLine == correctText.<span style="color: black;">upper</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    <span style="color: #808080; font-style: italic;">#print testLine('ALAS POOR YORICK I KNEW HIM HORATIO')</span>
    <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
       currentLoopCounter += <span style="color: #ff4500;">1</span>
       line = createRandomLine<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
       <span style="color: #ff7700;font-weight:bold;">if</span> testLine<span style="color: black;">&#40;</span>line<span style="color: black;">&#41;</span> == <span style="color: #008000;">True</span>:
           endTime = <span style="color: #dc143c;">time</span>.<span style="color: black;">localtime</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'Started: %s'</span> <span style="color: #66cc66;">%</span> startTime<span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'Ended  : %s'</span> <span style="color: #66cc66;">%</span> endTime<span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'Total Iterations: %s'</span> <span style="color: #66cc66;">%</span> currentLoopCounter<span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'MONKEY  LINE: %s'</span> <span style="color: #66cc66;">%</span> line<span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'DESIRED LINE: %s'</span> <span style="color: #66cc66;">%</span> correctText<span style="color: black;">&#41;</span>
           <span style="color: #ff7700;font-weight:bold;">break</span>
      <span style="color: #ff7700;font-weight:bold;">else</span>:
           <span style="color: #ff7700;font-weight:bold;">print</span> line, currentLoopCounter</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2007/02/14/a-million-monkeys-making-shakespeare/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Kodak Gallery RipAndZipper</title>
		<link>http://bigbadcode.com/2007/01/18/kodak-gallery-ripandzipper/</link>
		<comments>http://bigbadcode.com/2007/01/18/kodak-gallery-ripandzipper/#comments</comments>
		<pubDate>Thu, 18 Jan 2007 19:05:44 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[for:elzr]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2007/01/18/kodak-gallery-ripandzipper/</guid>
		<description><![CDATA[After my recent wedding Jody and I were getting lots of invitations to view Kodak Easy Share photo galleries.

Unfortunately there is no ability to download quality copies of the images you are looking at.
Fortunately however I know me some intarweb. So without further ado I am happy to introduce RipAndZipKodakGallery.
Basically this a command anyone can [...]]]></description>
			<content:encoded><![CDATA[<p>After my recent <a href="http://picasaweb.google.com/jodybloom">wedding</a> Jody and I were getting lots of invitations to view Kodak Easy Share photo galleries.</p>
<p><img src="http://www.kodakgallery.com/images/share/KESG_email_en_US.gif" /></p>
<p>Unfortunately there is no ability to download quality copies of the images you are looking at.</p>
<p>Fortunately however I know me some intarweb. So without further ado I am happy to introduce RipAndZipKodakGallery.</p>
<p>Basically this a command anyone can use to rip through any Kodak gallery and create a Zip file of all the pictures and download it to your computer.</p>
<p><strong>How do I use it?</strong></p>
<p>The easiest way to use it is with this bookmarklet: <a href="javascript:(function(){ var n = 1, f='http://yubnub.org/parser/parse?command=RipZipKodakGallery',w=window,d=document,r,u,s;s = location.href;u = f + encodeURIComponent(' '+s).replace(new RegExp('%'+'20','g'),'+');if(n) w.open(u); })()">RipAndZipKodak</a></p>
<ul>
<li>To install you simply drag the bookmarklet onto your browsers bookmark toolbar.</li>
<li>To use the bookmarklet you simply press the button when you are viewing the gallery. Thats it.</li>
</ul>
<p>Another way to use it is through the <a href="http://yubnub.org/kernel/man?args=RipZipKodakGallery">YubNub </a>interface<a href="http://yubnub.org"><br />
</a></p>
<ul>
<li>From the YubNub command line you enter this command:</li>
<li>RipZipKodakGallery http://www.kodakgallery.com/Slideshow.jsp?Uc=plr4ibx.lk0n0q9&amp;Uy=cmi7nr</li>
<li>Replace http://&#8230; with the url for the gallery you want to RipAndZip</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2007/01/18/kodak-gallery-ripandzipper/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Python reverse string method</title>
		<link>http://bigbadcode.com/2006/09/25/python-reverse-string-method/</link>
		<comments>http://bigbadcode.com/2006/09/25/python-reverse-string-method/#comments</comments>
		<pubDate>Mon, 25 Sep 2006 18:44:33 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/2006/09/25/python-reverse-string-method/</guid>
		<description><![CDATA[Saw this easy way to reverse a string in python today, over at Answer My Searches
Here&#8217;s how to do it:

exampleString = 'Hey there fancy pants'
reversedString = exampleString&#91;::-1&#93;
print reversedString
&#62;&#62; stnap ycnaf ereht yeH

This works because a String is a sequence type in python and you can apply all the &#8217;slicing&#8217; syntax you want to it. So [...]]]></description>
			<content:encoded><![CDATA[<p>Saw this easy way to reverse a string in python today, over at <a href="http://www.answermysearches.com/index.php/super-easy-way-to-reverse-a-string-in-python/188/">Answer My Searches</a></p>
<p>Here&#8217;s how to do it:</p>

<div class="wp_syntax"><div class="code"><pre class="python python" style="font-family:monospace;">exampleString = <span style="color: #483d8b;">'Hey there fancy pants'</span>
reversedString = exampleString<span style="color: black;">&#91;</span>::-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> reversedString
<span style="color: #66cc66;">&gt;&gt;</span> stnap ycnaf ereht yeH</pre></div></div>

<p>This works because a String is a sequence type in python and you can apply all the &#8217;slicing&#8217; syntax you want to it. So in this case [::-1] is saying, taking the string sequence start from the beginning &#8216;:&#8217; go to the end &#8216;:&#8217; and step through it in reverse (-1).</p>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2006/09/25/python-reverse-string-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
