<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Just another hack a day.</description><title>LifeHack</title><generator>Tumblr (3.0; @jimlifehack)</generator><link>http://www.lifehack.com/</link><item><title>"Want to write shorter, cleaner code? Have an unfortunate situation where you need to fit as much as..."</title><description>“Want to write shorter, cleaner code? Have an unfortunate situation where you need to fit as much as you can in one expression? Prefer a quick dose of hacks to spending the rest of your life reading the docs? You’ve come to the right place. We start out with some quick tricks that you might have figured out if you’ve spent some time with Python, but I promise there’s more crazy stuff towards the bottom.”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;&lt;p&gt;&lt;a href="http://www.siafoo.net/article/52"&gt;Python Tips, Tricks, and Hacks - Siafoo&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a great python reference site, it cleared up my understanding of list comprehensions within python (and a few other things, to boot!)&lt;/p&gt;&lt;/em&gt;</description><link>http://www.lifehack.com/post/736764750</link><guid>http://www.lifehack.com/post/736764750</guid><pubDate>Fri, 25 Jun 2010 22:03:50 -0500</pubDate></item><item><title>Fun with python &amp; iTunes and list comprehensions</title><description>&lt;p&gt;I wanted to verify that all of my songs in my iTunes library existed on my local filesystem, and vice versa, so I turned to python to help me out. I exported the entire Music library from iTunes as an &amp;#8220;m3u&amp;#8221; playlist called &amp;#8220;Music.m3u&amp;#8221;, then used python to compare and contrast. Code below:&lt;/p&gt;
&lt;pre&gt;#!/usr/bin/python
# -*- mode: Python; tab-width: 4; indent-tabs-mode: nil; -*-
# ex: set tabstop=4 softtabstop=1 shiftwidth=4 expandtab:
# Please do not change the two lines above. See PEP 8, PEP 263.
import os

library_path = '~/Music/iTunes/iTunes Music/'
library_path = os.path.expanduser(library_path)

m3u_songs_file = open('Music.m3u')
m3u_songs = m3u_songs_file.readline().split('\r')
m3u_songs = [song for song in m3u_songs if '#EXT' not in song]
m3u_songs = [song for song in m3u_songs if song != '']

local_filter = ['/.DS_Store', '/.iTunes Preferences.plist',
                '/Mobile Applications', '/Ringtones']

local_songs = []
for root, dirs, files in os.walk(library_path):
    for file in files:
        songpath = os.path.join(root, file)
        skip = False
        for filterstr in local_filter:
            if filterstr in songpath:
                skip = True
            if not skip:
                local_songs.append(songpath)

missing_from_local = [song for song in m3u_songs if song not in local_songs]
missing_from_m3u = [song for song in local_songs if song not in m3u_songs]

print "songs in iTunes but not found on local filesystem:"
if not missing_from_local:
    print "\tNONE!"
for song in missing_from_local:
    print "\t", song

print "songs in the local filesystem but not in iTunes:"
if not missing_from_m3u:
    print "\tNONE!"
for song in missing_from_m3u:
    print "\t", song
&lt;/pre&gt;
&lt;div&gt;&lt;/div&gt;</description><link>http://www.lifehack.com/post/736721447</link><guid>http://www.lifehack.com/post/736721447</guid><pubDate>Fri, 25 Jun 2010 21:50:00 -0500</pubDate></item></channel></rss>
