<?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>Lee Clemmer</title>
	<atom:link href="http://www.leeclemmer.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leeclemmer.com</link>
	<description></description>
	<lastBuildDate>Tue, 17 Jan 2012 19:10:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Filip Dujardin</title>
		<link>http://www.leeclemmer.com/2012/01/filip-dujardin/</link>
		<comments>http://www.leeclemmer.com/2012/01/filip-dujardin/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 19:07:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Visual Arts]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[photomontage]]></category>

		<guid isPermaLink="false">http://www.leeclemmer.com/?p=128</guid>
		<description><![CDATA[Via the ever-excellent Jörg Colberg (ein Deutscher wie ich soweit ich weiss ) I just found out about Filip Dujardin, who has a number of excellent photomontages.  The main thrust of these montages is architectural, and although we know these creations to be fake, they reflect the absurdity and banality of much of modern architecture. The [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Filip Dujardin on Conscientous" href="http://jmcolberg.com/weblog/2012/01/filip_dujardin/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+jmcolberg%2Fconscientious+%28Conscientious%29&amp;utm_content=Google+Reader">Via the ever-excellent Jörg Colberg</a> (ein Deutscher wie ich soweit ich weiss <img src='http://www.leeclemmer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) I just found out about <a title="Filip Dujardin" href="http://www.filipdujardin.be/">Filip Dujardin</a>, who has a number of excellent photomontages.  The main thrust of these montages is architectural, and although we know these creations to be fake, they reflect the absurdity and banality of much of modern architecture.</p>
<p>The photoshopping is quite excellent.  The only real bummer is his website, which is inexplicably all flash-based (baaad idea) and consequently distorts the pictures depending on your resolution.</p>
<div id="attachment_130" class="wp-caption alignnone" style="width: 560px"><a href="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-01.png"><img class=" wp-image-130 " title="Fictions by Filip Dujardin 01" src="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-01.png" alt="Fictions by Filip Dujardin 01" width="550" /></a><p class="wp-caption-text">Fictions by Filip Dujardin 01</p></div>
<div id="attachment_131" class="wp-caption alignnone" style="width: 560px"><a href="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-02.png"><img class=" wp-image-131 " title="Fictions by Filip Dujardin 02" src="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-02.png" alt="Fictions by Filip Dujardin 02" width="550" /></a><p class="wp-caption-text">Fictions by Filip Dujardin 02</p></div>
<div id="attachment_132" class="wp-caption alignnone" style="width: 560px"><a href="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-03.png"><img class=" wp-image-132 " title="Fictions by Filip Dujardin 03" src="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-03.png" alt="Fictions by Filip Dujardin 03" width="550" /></a><p class="wp-caption-text">Fictions by Filip Dujardin 03</p></div>
<div id="attachment_133" class="wp-caption alignnone" style="width: 560px"><a href="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-04.png"><img class=" wp-image-133 " title="Fictions by Filip Dujardin 04" src="http://www.leeclemmer.com/wp-content/uploads/2012/01/Fictions-by-Filip-Dujardin-04.png" alt="Fictions by Filip Dujardin 04" width="550" /></a><p class="wp-caption-text">Fictions by Filip Dujardin 04</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2012/01/filip-dujardin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experiments in Photomontage</title>
		<link>http://www.leeclemmer.com/2012/01/experiments-in-photomontage/</link>
		<comments>http://www.leeclemmer.com/2012/01/experiments-in-photomontage/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 03:41:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Visual Arts]]></category>
		<category><![CDATA[magical realism]]></category>
		<category><![CDATA[photomontage]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=106</guid>
		<description><![CDATA[I&#8217;ve recently become quite interested in the intersection of photomontage &#8211; cutting and joining and number of different photographs together &#8211; and magical realism, which is a kind of intense meditation on reality to the point of hyperreality, possibly with the inclusion of elements of the fantastic. Last June, newly equipped with my Canon 60D, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently become quite interested in the intersection of photomontage &#8211; cutting and joining and number of different photographs together &#8211; and magical realism, which is a kind of intense meditation on reality to the point of hyperreality, possibly with the inclusion of elements of the fantastic.</p>
<p>Last June, newly equipped with my Canon 60D, I decided to do a little experiment in photoshopping a scene together in my home office at the time.</p>
<div id="attachment_117" class="wp-caption alignnone" style="width: 560px"><a href="http://www.leeclemmer.com/wp-content/uploads/2012/01/Hand-in-Couch.png"><img class=" wp-image-117   " title="Hand in Couch" src="http://www.leeclemmer.com/wp-content/uploads/2012/01/Hand-in-Couch.png" alt="Hand in Couch" width="550" /></a><p class="wp-caption-text">Hand in Couch</p></div>
<p>I just used what was immediately around me.  I took several shots of my arm on the couch and of just the couch itself, and some photoshopping later we get this image which looks real but we yet know cannot be real.  I think this juxtaposition is kind of creepy and unsettling.</p>
<p>Just recently I&#8217;ve read a lot of <a title="Strobist" href="http://strobist.blogspot.com/">strobist.com</a> &#8211; that site is awesome.  Armed with my brother&#8217;s Canon Speedlite 430 EX as well as a light stand + umbrella I&#8217;ve been wreaking some studio quality lighting havoc recently.  Catching up on the work of Dave Hill I got to thinking about how to get multi-light pictures having only one light source (my flash) and possibly outside ambient light.  I thought why not independently light areas of the scene and then stitch them together in PS.  Basically light painting with a flash and shoot-through umbrella.</p>
<p>So I took roughly 60-70 pictures and ultimately ended up taking 32 of them and putting them together in PS.</p>
<div id="attachment_122" class="wp-caption alignnone" style="width: 560px"><a href="http://www.leeclemmer.com/wp-content/uploads/2012/01/Lee-X-3.jpg"><img class=" wp-image-122 " title="Lee X 3" src="http://www.leeclemmer.com/wp-content/uploads/2012/01/Lee-X-3.jpg" alt="Lee X 3" width="550" /></a><p class="wp-caption-text">Lee X 3</p></div>
<p>All in all this picture was 61 layers (of which 32 were photos) totaling 3GB!  Consequently found out about the .psb file extension through this project, which is Adobe&#8217;s large file format as .psd&#8217;s only go up to 2 gigs.</p>
<p>Anyway, most of the work was actually in the brackground.  I basically used the light parts of each component picture and used the <em>Lighten</em> blend mode to blend the pics on top of one another.  Getting it just right requires a fair amount fine-tuning, but that was the basic process.  I used the analogy of <em>additive lighting</em> whereby I started with a black background and added light selectively to build up the picture.</p>
<p>The end result is quite interesting. The room is very unrealistically lit and there isn&#8217;t an obvious light source.  So just the room in and of itself is &#8220;off&#8221; somehow but it shows much greater detail &#8211; hyperreal so to speak.  Then of course three versions of me cannot be, yet it looks real&#8230; though in a fake way.  Some of the shadows could be improved and are to me giveaways (e.g. the right arm of me sitting in the recliner, or the right hand of me on the ground), but you don&#8217;t immediately notice it.</p>
<p>To me a quite fascinating space, the edge between reality and imagination.  Though all photography is an illusion (an image on paper or screen ain&#8217;t the real thing), there&#8217;s an expectation that a photo depicts some kind of reality objectively.  Of course there&#8217;s a huge amount of editing (cropping, lighting, etc.) but I guess the expectation is that I could go out and see a depicted scene for myself.  Playing with this expectation through photomontage opens up endless possibilities to surprise and challenge the viewer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2012/01/experiments-in-photomontage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some new videos by my bro Ian</title>
		<link>http://www.leeclemmer.com/2009/11/some-new-videos-by-my-bro-ian/</link>
		<comments>http://www.leeclemmer.com/2009/11/some-new-videos-by-my-bro-ian/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 21:36:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Visual Arts]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=100</guid>
		<description><![CDATA[Some seriously heady shit: superfLOW &#8211; The Unthinkable from Ian Clemmer on Vimeo. superfLOW &#8211; Galactic Flow from Ian Clemmer on Vimeo. SUPER FLOW from Ian Clemmer on Vimeo.]]></description>
			<content:encoded><![CDATA[<p>Some seriously heady shit:</p>
<p><object width="400" height="225" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7318993&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed width="400" height="225" type="application/x-shockwave-flash" src="http://vimeo.com/moogaloop.swf?clip_id=7318993&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowfullscreen="true" allowscriptaccess="always" /></object></p>
<p><a href="http://vimeo.com/7318993">superfLOW &#8211; The Unthinkable</a> from <a href="http://vimeo.com/phizikl">Ian Clemmer</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><object width="400" height="220" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7262618&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed width="400" height="220" type="application/x-shockwave-flash" src="http://vimeo.com/moogaloop.swf?clip_id=7262618&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowfullscreen="true" allowscriptaccess="always" /></object></p>
<p><a href="http://vimeo.com/7262618">superfLOW &#8211; Galactic Flow</a> from <a href="http://vimeo.com/phizikl">Ian Clemmer</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><object width="400" height="220" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7260715&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed width="400" height="220" type="application/x-shockwave-flash" src="http://vimeo.com/moogaloop.swf?clip_id=7260715&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowfullscreen="true" allowscriptaccess="always" /></object></p>
<p><a href="http://vimeo.com/7260715">SUPER FLOW</a> from <a href="http://vimeo.com/phizikl">Ian Clemmer</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/11/some-new-videos-by-my-bro-ian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Most Prolific Blogger Ever</title>
		<link>http://www.leeclemmer.com/2009/11/most-prolific-blogger-ever/</link>
		<comments>http://www.leeclemmer.com/2009/11/most-prolific-blogger-ever/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 21:03:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=97</guid>
		<description><![CDATA[Is someone other than me.  I have to say, it is quite odd to me that I have the urge to really put energy into a blogging effort but nonetheless never am able to do so.  If you really want to be successful, it&#8217;s always about having a laser focus on niche content, and although [...]]]></description>
			<content:encoded><![CDATA[<p>Is someone other than me.  I have to say, it is quite odd to me that I have the urge to really put energy into a blogging effort but nonetheless never am able to do so.  If you really want to be successful, it&#8217;s always about having a laser focus on niche content, and although there are numerous niches I am quite interested in, I feel that focusing on any one really takes away from the others.</p>
<p>So I end up not writing anything at all.</p>
<p>Clearly my interest in Python was short-lived.  Not really surprising.  My fickle mind apparently enjoys intense but brief relationships with various subject matter.  Which is great for overall breadth of knowledge, but I never get to be intimately involved with the devil in the details.  Oh well.  I suppose the best thing to do is to simply embrace this shotgun approach to interest and learning and be comfortable with the fact that this place will have no discernible focus, but may be all over the place.</p>
<p>You should be comfortable with that too.  On with the show.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/11/most-prolific-blogger-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good article on Javascript arrays</title>
		<link>http://www.leeclemmer.com/2009/06/good-article-on-javascript-arrays/</link>
		<comments>http://www.leeclemmer.com/2009/06/good-article-on-javascript-arrays/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 14:33:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=94</guid>
		<description><![CDATA[Mastering Javascript Arrays]]></description>
			<content:encoded><![CDATA[<p><a title="Mastering Javascript Arrays" href="http://www.hunlock.com/blogs/Mastering_Javascript_Arrays">Mastering Javascript Arrays</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/06/good-article-on-javascript-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful WordPress Links</title>
		<link>http://www.leeclemmer.com/2009/06/useful-wordpress-links/</link>
		<comments>http://www.leeclemmer.com/2009/06/useful-wordpress-links/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 15:44:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=92</guid>
		<description><![CDATA[While I&#8217;m at it, lemme just put in one place the most frequently used WordPress links: Delicious Bookmarks (this should really act as this post itself&#8230; what are ya gonna do?) The Loop Template Tags Query Posts]]></description>
			<content:encoded><![CDATA[<p>While I&#8217;m at it, lemme just put in one place the most frequently used WordPress links:</p>
<ul>
<li><a title="http://www.delicious.com/clemmerl/wordpress" href="http://www.delicious.com/clemmerl/wordpress">Delicious Bookmarks</a> (this should really act as this post itself&#8230; what are ya gonna do?)</li>
<li><a href="http://codex.wordpress.org/The_Loop">The Loop</a></li>
<li><a href="http://codex.wordpress.org/Template_Tags/">Template Tags</a></li>
<li><a href="http://codex.wordpress.org/Template_Tags/query_posts">Query Posts</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/06/useful-wordpress-links/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Backing up your WordPress database</title>
		<link>http://www.leeclemmer.com/2009/06/backing-up-your-wordpress-database/</link>
		<comments>http://www.leeclemmer.com/2009/06/backing-up-your-wordpress-database/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 15:37:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=89</guid>
		<description><![CDATA[Originally posted on my old blog, reposting due to its continued usefulness for myself You can find the full instructions to back up your WordPress database over at WordPress.org, but here are the settings needed for a phpMyAdmin export (more for my own reference than anything else): Select ONLY those that hold your WordPress site. Check the [...]]]></description>
			<content:encoded><![CDATA[<p><em>Originally posted on my old blog, reposting due to its continued usefulness for myself <img src='http://www.leeclemmer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
<p>You can find the full <a title="Instructions to back up your WordPress database" href="http://codex.wordpress.org/WordPress_Backups">instructions to back up your WordPress database</a> over at WordPress.org, but here are the settings needed for a phpMyAdmin export (more for my own reference than anything else):</p>
<ol>
<li><strong>Select ONLY those that hold your WordPress site.</strong></li>
<li>Check the “Add DROP TABLE” box.</li>
<li>Check the “Complete inserts” box.</li>
<li>Check the “Save as File” box</li>
<li>Check the “None” for compression. If your database is very large use a compression method.</li>
<li>Click Go. The data will now be saved into your computer.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/06/backing-up-your-wordpress-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML and XSLT Standards</title>
		<link>http://www.leeclemmer.com/2009/05/xml-and-xslt-standards/</link>
		<comments>http://www.leeclemmer.com/2009/05/xml-and-xslt-standards/#comments</comments>
		<pubDate>Sun, 03 May 2009 15:55:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[standards w3c recommendation]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=84</guid>
		<description><![CDATA[I just picked up O&#8217;Reilly&#8217;s big &#8220;XSLT&#8221; book by Doug Tidwell which has a ton of good stuff in it.  Here are list of links to XML and XSLT standards that Doug covers in the first chapter. XML Standards XML 1.0: Extensible Markup Language (XML) 1.0 (Fifth Edition) W3C Recommendation 26 November 2008 XML 1.1: Extensible Markup [...]]]></description>
			<content:encoded><![CDATA[<p>I just picked up <a href="http://www.amazon.com/gp/product/0596527217?ie=UTF8&amp;tag=drinbl-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0596527217"><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=drinbl-20&amp;l=as2&amp;o=1&amp;a=0596527217" alt="" width="1" height="1" border="0" />O&#8217;Reilly&#8217;s big &#8220;XSLT&#8221; book by Doug Tidwell</a> which has a ton of good stuff in it.  Here are list of links to XML and XSLT standards that Doug covers in the first chapter.</p>
<p><span id="more-84"></span></p>
<h4>XML Standards</h4>
<ul>
<li><a title="Extensible Markup Language (XML) 1.0 (Fifth Edition) W3C Recommendation 26 November 2008" href="http://www.w3.org/TR/xml/">XML 1.0</a>: Extensible Markup Language (XML) 1.0 (Fifth Edition) W3C Recommendation 26 November 2008</li>
<li><a title="Extensible Markup Language (XML) 1.1 (Second Edition) W3C Recommendation 16 August 2006, edited in place 29 September 2006" href="http://www.w3.org/TR/xml11/">XML 1.1</a>: Extensible Markup Language (XML) 1.1 (Second Edition) W3C Recommendation 16 August 2006, edited in place 29 September 2006</li>
<li><a title="Extensible Stylesheet Language (XSL) Version 1.1 W3C Recommendation 05 December 2006" href="http://www.w3.org/TR/xsl/">XSL 1.1</a>: Extensible Stylesheet Language (XSL) Version 1.1 W3C Recommendation 05 December 2006
<ul>
<li><a title="Apache FOP (Formatting Objects Processor)" href="http://xmlgraphics.apache.org/fop/">FOP</a>: Apache FOP (Formatting Objects Processor) for (mainly) output to PDF</li>
</ul>
</li>
<li>XML Schema
<ul>
<li><a title="XML Schema Part 0: Primer Second Edition W3C Recommendation 28 October 2004" href="http://www.w3.org/TR/xmlschema-0/">XML Schema Part 0</a>: Primer Second Edition W3C Recommendation 28 October 2004</li>
<li><a title="XML Schema Part 1: Structures Second Edition W3C Recommendation 28 October 2004" href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1</a>: Structures Second Edition W3C Recommendation 28 October 2004</li>
<li><a title="XML Schema Part 2: Datatypes Second Edition W3C Recommendation 28 October 2004" href="http://www.w3.org/TR/xmlschema-2/">XML Schema Part 2</a>: Datatypes Second Edition W3C Recommendation 28 October 2004</li>
</ul>
</li>
<li><a title="OASIS Relax NG TC" href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=relax-ng">OASIS Relax NG TC</a></li>
<li><a title="Schematron" href="http://www.schematron.com/">Schematron</a></li>
<li><a title="SAX: Simple API for XML" href="http://www.saxproject.org/">SAX: Simple API for XML</a></li>
<li><a title="DOM: Document Object Model" href="http://www.w3.org/DOM/">DOM</a>: Document Object Model</li>
<li><a title="Namespaces in XML 1.0 (Second Edition) W3C Recommendation 16 August 2006" href="http://www.w3.org/TR/xml-names/">Namespaces in XML 1.0</a> (Second Edition) W3C Recommendation 16 August 2006</li>
<li><a title="Namespaces in XML 1.1 (Second Edition) W3C Recommendation 16 August 2006" href="http://www.w3.org/TR/xml-names11/">Namespaces in XML 1.1</a> (Second Edition) W3C Recommendation 16 August 2006</li>
<li><a title="Associating Style Sheets with XML documents Version 1.0 W3C Recommendation 29 June 1999" href="http://www.w3.org/TR/xml-stylesheet/">Associating Style Sheets with XML documents</a> Version 1.0 W3C Recommendation 29 June 1999</li>
<li><a title="Scalable Vector Graphics (SVG) 1.1 Specification W3C Recommendation 14 January 2003, edited in place 30 April 2009" href="http://www.w3.org/TR/SVG/">SVG</a>: Scalable Vector Graphics (SVG) 1.1 Specification W3C Recommendation 14 January 2003, edited in place 30 April 2009</li>
<li><a title="XPointer Framework W3C Recommendation 25 March 2003" href="http://www.w3.org/TR/xptr-framework/">XPointer</a>: XPointer Framework W3C Recommendation 25 March 2003</li>
<li><a title="XML Linking Language (XLink) Version 1.0 W3C Recommendation 27 June 2001" href="http://www.w3.org/TR/xlink/">XLink</a>: XML Linking Language (XLink) Version 1.0 W3C Recommendation 27 June 2001</li>
</ul>
<h4>XSLT Standards</h4>
<ul>
<li><a title="XSL Transformations (XSLT) Version 1.0 W3C Recommendation 16 November 1999" href="http://www.w3.org/TR/xslt">XSLT 1.0</a>: XSL Transformations (XSLT) Version 1.0 W3C Recommendation 16 November 1999</li>
<li><a title="XSL Transformations (XSLT) Version 2.0 W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xslt20/">XSLT 2.0</a>: XSL Transformations (XSLT) Version 2.0 W3C Recommendation 23 January 2007</li>
<li><a title="XML Path Language (XPath) Version 1.0 W3C Recommendation 16 November 1999" href="http://www.w3.org/TR/xpath">XPath 1.0</a>: XML Path Language (XPath) Version 1.0 W3C Recommendation 16 November 1999</li>
<li><a title="XML Path Language (XPath) 2.0 W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xpath20/">XPath 2.0</a>: XML Path Language (XPath) 2.0 W3C Recommendation 23 January 2007</li>
<li><a title="XQuery 1.0 and XPath 2.0 Data Model (XDM) W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xpath-datamodel/">XDM</a>: XQuery 1.0 and XPath 2.0 Data Model (XDM) W3C Recommendation 23 January 2007</li>
<li><a title="XQuery 1.0 and XPath 2.0 Functions and Operators W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xpath-functions/">F&amp;O</a>: XQuery 1.0 and XPath 2.0 Functions and Operators W3C Recommendation 23 January 2007</li>
<li>XQuery 1.0 and XPath 2.0 <a title="XQuery 1.0 and XPath 2.0 Formal Semantics W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xquery-semantics/">Formal Semantics</a> W3C Recommendation 23 January 2007</li>
<li>XSLT 2.0 and XQuery 1.0 <a title="XSLT 2.0 and XQuery 1.0 Serialization W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xslt-xquery-serialization/">Serialization</a> W3C Recommendation 23 January 2007</li>
<li><a title="XQuery 1.0: An XML Query Language W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xquery/">XQuery 1.0</a>: An XML Query Language W3C Recommendation 23 January 2007</li>
<li><a title="XML Syntax for XQuery 1.0 (XQueryX) W3C Recommendation 23 January 2007" href="http://www.w3.org/TR/xqueryx/">XQueryX</a>: XML Syntax for XQuery 1.0 (XQueryX) W3C Recommendation 23 January 2007</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/05/xml-and-xslt-standards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chapter 3: Notes on “Dive Into Python” by Mark Pilgrim</title>
		<link>http://www.leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/</link>
		<comments>http://www.leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 16:11:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[tuple]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=43</guid>
		<description><![CDATA[Note: I’m currently in the process of learning Python.  These are notes on &#8220;Dive Into Python&#8221; by Mark Pilgrim (also available online), an excellent book if you&#8217;re like me and learn by the &#8220;do first, understand later&#8221; method. In Chapter 3, Mark introduces: Dictionaries Lists Tuples Variables Strings Dictionaries A dictionary defines a one-to-one relationship between a key and [...]]]></description>
			<content:encoded><![CDATA[<p><a name="top"></a><em>Note: I’m currently in the process of learning Python.  These are notes on </em><a href="http://www.amazon.com/gp/product/1590593561?ie=UTF8&amp;tag=drinbl-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590593561"><em>&#8220;Dive Into Python&#8221;</em></a><em><img src="http://www.assoc-amazon.com/e/ir?t=drinbl-20&amp;l=as2&amp;o=1&amp;a=1590593561" alt="" width="1" height="1" border="0" /> by Mark Pilgrim (also available </em><a title="Dive Into Python" href="http://diveintopython.org/"><em>online</em></a><em>), an excellent book if you&#8217;re like me and learn by the &#8220;do first, understand later&#8221; method.</em></p>
<p>In Chapter 3, Mark introduces:</p>
<ul>
<li><a href="http://leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/#dictionaries">Dictionaries</a></li>
<li><a href="http://leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/#lists">Lists</a></li>
<li><a href="http://leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/#tuples">Tuples</a></li>
<li><a href="http://leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/#variables">Variables</a></li>
<li><a href="http://leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/#strings">Strings</a></li>
</ul>
<p><span id="more-43"></span></p>
<p><a name="dictionaries"></a></p>
<h4>Dictionaries</h4>
<p>A dictionary defines a one-to-one relationship between a <em>key</em> and a <em>value.  </em>Here&#8217;s how you define a dictionary:</p>
<pre>&gt;&gt;&gt; <strong>d = {"firstname":"lee","lastname":"clemmer","age":"26"}</strong></pre>
<p>To <strong>access</strong> the value of a specific key:</p>
<pre>&gt;&gt;&gt; <strong>d["firstname"]</strong>
'lee'</pre>
<p>Note, however, that you cannot get keys by values:</p>
<pre>&gt;&gt;&gt; d["clemmer"]

Traceback (most recent call last):
  File "&lt;pyshell#22&gt;", line 1, in &lt;module&gt;
    d["clemmer"]
KeyError: 'clemmer'</pre>
<p>To <strong>add</strong> a key:</p>
<pre>&gt;&gt;&gt; <strong>d["hometown"] = "Bremen"</strong>
&gt;&gt;&gt; d
{'lastname': 'clemmer', 'age': '26', 'firstname': 'lee', 'hometown': 'Bremen'}</pre>
<p>To <strong>overwrite</strong> a key:</p>
<pre>&gt;&gt;&gt; <strong>d["age"] = "21"</strong>
&gt;&gt;&gt; d
{'lastname': 'clemmer', 'age': '21', 'firstname': 'lee', 'hometown': 'Bremen'}</pre>
<p>Note that this is the same syntax as <em>adding</em> a key.</p>
<p>To <strong>delete</strong> a key:</p>
<pre>&gt;&gt;&gt; <strong>del</strong> <strong>d["age"]</strong>
&gt;&gt;&gt; d
{'lastname': 'clemmer', 'firstname': 'lee', 'hometown': 'Bremen'}</pre>
<p>To <strong>clear</strong> the whole dictionary:</p>
<pre>&gt;&gt;&gt; d.<strong>clear()</strong>
&gt;&gt;&gt; d
{}</pre>
<p>Important to note:</p>
<ul>
<li>Dictionaries are unordered.  This is why the sequence they appear in seems random.  It is.  They&#8217;re not &#8220;out of order&#8221;, there <em>is</em> no order.</li>
<li>Dictionaries cannot have duplicate keys</li>
<li>Dictionary keys are case-sensitive: d["key"] and d["Key"] are different</li>
<li>Dictionary values can be of any datatype (strings, integers, objects, dictionaries, etc.)</li>
<li>Dictonary keys can only be certain datatypes (immutables, like strings, integers, or tuples of immutables)</li>
<li>Both key and value datatypes can be mixed and matched within a single dictionary</li>
</ul>
<p>Dictionary have a built-in function that returns a list of tuples of all or some of the data in the dictionary:</p>
<pre>&gt;&gt;&gt; d.<strong>keys()</strong>
['lastname', 'age', 'firstname']
&gt;&gt;&gt; d.<strong>values()</strong>
['clemmer', '26', 'lee']
&gt;&gt;&gt; d.<strong>items()</strong>
[('lastname', 'clemmer'), ('age', '26'), ('firstname', 'lee')]</pre>
<p>Although dictionaries are unordered, note that <em>d.values()[n] == d.keys()[n]</em> for all values of n.</p>
<p><em>Further reading on dictionaries:</em></p>
<ul>
<li><a title="&quot;Dictionaries&quot; in &quot;How to Think Like a Computer Scientist: Learning With Python&quot;" href="http://www.openbookproject.net//thinkCSpy/ch12.xhtml">&#8220;Dictionaries&#8221;</a> in <a title="&quot;How to Think Like a Computer Scientist: Learning With Python&quot;" href="http://www.openbookproject.net//thinkCSpy/">&#8220;How to Think Like a Computer Scientist: Learning With Python&#8221;</a></li>
<li><a title="Questions about dictionaries on the Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/541">Questions about dictionaries</a> on the <a title="Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/199">Python Knowledge Base</a></li>
<li><a title="&quot;To sort a dictionary&quot; in the Python Cookbook" href="http://code.activestate.com/recipes/52306/">&#8220;To sort a dictionary&#8221;</a> in the <a title="Python Cookbook" href="http://code.activestate.com/recipes/langs/python/">Python Cookbook</a></li>
<li><a title="&quot;Mapping Types -- dict&quot; in the Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/typesmapping.html">&#8220;Mapping Types &#8212; dict&#8221;</a> in the <a title="Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/lib.html">Python Library Reference</a></li>
</ul>
<p><a name="lists"></a></p>
<h4>Lists</h4>
<p><a href="#top">Top</a></p>
<p>Lists are <em>ordered</em> sets of elements, as opposed to <em>unordered</em> dictionaries.  They are similar to zero-based arrays.</p>
<p>To <strong>create </strong>a list:</p>
<pre>&gt;&gt;&gt; <strong>list = ["1", 2, "three", 4, "lee"]</strong>
&gt;&gt;&gt; list
['1', 2, 'three', 4, 'lee']</pre>
<p>As you can see, I&#8217;ve mixed and matched strings and integers.</p>
<p>To <strong>access</strong> one of the elements, you indicate its position, with the first one being 0:</p>
<pre>&gt;&gt;&gt; list<strong>[0]</strong>
'1'
&gt;&gt;&gt; list<strong>[3]</strong>
4</pre>
<p>You can also use a <em><strong>negative </strong><strong><span style="font-style: normal;">index</span></strong></em> to access elements.  The last element always corresponds to -1, or li[-n] == li[len(li) - n]:</p>
<pre>&gt;&gt;&gt; list<strong>[-1]</strong>
'lee'
&gt;&gt;&gt; list<strong>[-5]</strong>
'1'</pre>
<p>You can <strong>slice</strong> a list by specifying the first index and the index <em>after</em> the last element you want returned, which is a bit counterintuitive.  For example:</p>
<pre>&gt;&gt;&gt; list = ["one", "two", "three", "four", "five"]
&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five']
&gt;&gt;&gt; list<strong>[1:3]</strong>
['two', 'three']
&gt;&gt;&gt; list<strong>[-4:-1]</strong>
['two', 'three', 'four']
&gt;&gt;&gt; list<strong>[:3]</strong>
['one', 'two', 'three']
&gt;&gt;&gt; list<strong>[3:]</strong>
['four', 'five']
&gt;&gt;&gt; list<strong>[:]</strong>
['one', 'two', 'three', 'four', 'five']</pre>
<p>Some notes about these examples:</p>
<ul>
<li>[1:3] specifies element at index [1] (&#8216;two&#8217;) until element at index <em>before</em> [3], i.e. [2] (&#8216;three&#8217;)</li>
<li>Negative indices work as well</li>
<li>You can use shorthand: [:3] implies &#8220;start from index [0]&#8220;; [3:] implies &#8220;until <em>last</em> index&#8221;</li>
<li>[:] returns all list elements as a <em>copy</em> of that list</li>
</ul>
<p>There are several different ways to <strong>add</strong> elements onto or into a list:</p>
<pre>&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five']
&gt;&gt;&gt; list.<strong>append</strong><strong>("seven")</strong>
&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five', 'seven']
&gt;&gt;&gt; list.<strong>insert</strong><strong>(5,"six")</strong>
&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five', 'six', 'seven']
&gt;&gt;&gt; list.<strong>extend</strong><strong>(["eight","nine"])</strong>
&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']</pre>
<ul>
<li> <em>append</em> adds a single element to the end of list</li>
<li><em>insert </em>inserts an element and bumps up the element referenced in the call ([5] in the example: it inserted the string &#8220;six&#8221; in the sixth position at index [5])</li>
<li><em>extend</em> concatenates lists; you call it with <em>one list as the argument</em> as opposed to multiple arguments.  This adds each list element as a new element.  If you were to do append(["one","two"]) this would append a list as <em>one</em> element</li>
</ul>
<p>To <strong>query the length</strong> of a list, simply:</p>
<pre>&gt;&gt;&gt; <strong>len</strong><strong>(list)</strong>
9</pre>
<p>To <strong>search for the index<em> </em><span style="font-weight: normal;">of an element:</span></strong></p>
<pre><strong><span style="font-weight: normal;">&gt;</span><span style="font-weight: normal;">&gt;&gt; list.</span><span style="font-weight: normal;">index</span><span style="font-weight: normal;">('four')</span><span style="font-weight: normal;"> 3 &gt;&gt;&gt; list.index('ten') Traceback (most recent call last): File "&lt;pyshell#82&gt;", line 1, in &lt;module&gt; list.index('ten') ValueError: list.index(x): x not in list &gt;&gt;&gt; "ten" </span><span style="font-weight: normal;">in</span><span style="font-weight: normal;"> list False </span></strong></pre>
<ul>
<li><em>index </em>returns the index of the <em>first</em> occurrence of an element</li>
<li>search for an element that doesn&#8217;t exist raises an exception and crashes your program (instead of returning in invalid index)</li>
<li>to see if a value is present in a list, use <em>in</em>, which will return <em>True </em>or <em>False</em></li>
</ul>
<p>To <strong>delete</strong> an element from a list:</p>
<pre>&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
&gt;&gt;&gt; list.<strong>remove</strong><strong>('three')</strong>
&gt;&gt;&gt; list
['one', 'two', 'four', 'five', 'six', 'seven', 'eight', 'nine']
&gt;&gt;&gt; list.remove('three')

Traceback (most recent call last):
  File "&lt;pyshell#99&gt;", line 1, in &lt;module&gt;
    list.remove('three')
ValueError: list.remove(x): x not in list
&gt;&gt;&gt; list.<strong>pop()</strong>
'nine'
&gt;&gt;&gt; list
['one', 'two', 'four', 'five', 'six', 'seven', 'eight']</pre>
<ul>
<li><em>remove</em> removes <em>only</em> the first occurrence of the given value</li>
<li>if the value isn&#8217;t found, Python raises an exception</li>
<li><em>pop</em> does two things
<ol>
<li>removes the last element</li>
<li>returns that element</li>
</ol>
</li>
</ul>
<p>There are a number of different <strong>operators</strong> that you can use on lists:</p>
<pre>&gt;&gt;&gt; list = ["one", "two"]
&gt;&gt;&gt; list = <strong>list + ["three", "four"]</strong>
&gt;&gt;&gt; list
['one', 'two', 'three', 'four']
&gt;&gt;&gt; list <strong>+=</strong> ["five"]
&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five']
&gt;&gt;&gt; list <strong>*=</strong> 3
&gt;&gt;&gt; list
['one', 'two', 'three', 'four', 'five', 'one', 'two', 'three', 'four', 'five', 'one', 'two',
'three', 'four', 'five']
&gt;&gt;&gt; list = <strong>[1,2] * 4</strong>
&gt;&gt;&gt; list
[1, 2, 1, 2, 1, 2, 1, 2]</pre>
<ul>
<li>The + operator concatenates two lists into a <em>new</em> list. This is the same as the <em>extend</em> function, except that concatenation creates a new string, where as <em>extend</em> just extends an existing string, making it much faster, especially for large lists.</li>
<li>list += ["five"] is the same as list = list + ["five"] or list.extend(["five"])</li>
<li>The * operator acts as a repeater on a list</li>
</ul>
<p><em>Further reading on lists:</em></p>
<ul>
<li><a title="&quot;Lists&quot; in &quot;How to Think Like a Computer Scientist: Learning With Python&quot;" href="http://www.openbookproject.net//thinkCSpy/ch09.xhtml">&#8220;Lists&#8221;</a> in <a title="&quot;How to Think Like a Computer Scientist: Learning With Python&quot;" href="http://www.openbookproject.net//thinkCSpy/">&#8220;How to Think Like a Computer Scientist: Learning With Python&#8221;</a></li>
<li><a title="&quot;More on Lists&quot; in the Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/node7.html#SECTION007100000000000000000">&#8220;More on Lists&#8221;</a> in the <a title="Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/tut.html">Python Tutorial</a></li>
<li><a title="Questions about lists on the Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/540">Questions about lists</a> on the <a title="Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/199">Python Knowledge Base</a></li>
<li><a title="&quot;Mutable Sequence Types&quot; in the Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/typesseq-mutable.html">&#8220;Mutable Sequence Types&#8221; (all list functions)</a> in the <a title="Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/lib.html">Python Library Reference</a></li>
</ul>
<h4>Mapping Lists</h4>
<p><strong>List comprehension</strong> provides a way to map a list onto another list.  Note that this does not change the original list, unless you assign it as such:</p>
<pre>&gt;&gt;&gt; list = ["item 1", 2, "three", 4]
&gt;&gt;&gt; [elem*2 for elem in list]
['item 1item 1', 4, 'threethree', 8]
&gt;&gt;&gt; list
['item 1', 2, 'three', 4]
&gt;&gt;&gt; list = [elem*3 for elem in list]
&gt;&gt;&gt; list
['item 1item 1item 1', 6, 'threethreethree', 12]</pre>
<p>Further reading on list comprehension</p>
<ul>
<li><a title="&quot;List Comprehensions&quot; in the Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/node7.html#SECTION007140000000000000000">&#8220;List Comprehensions&#8221;</a> in the <a title="Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/tut.html">Python Tutorial</a></li>
</ul>
<p><a name="tuples"></a></p>
<h4>Tuples</h4>
<p><a href="#top">Top</a></p>
<p>A tuple is an <strong>immutable list</strong>.  That would be a list that you can&#8217;t change.  Once it&#8217;s created, you can&#8217;t change it. It&#8217;s immutable.  However, other than not changing, it acts very much like a list:</p>
<pre>&gt;&gt;&gt; t = ("lee","clemmer")
&gt;&gt;&gt; t
('lee', 'clemmer')
&gt;&gt;&gt; t[1]
'clemmer'
&gt;&gt;&gt; t[:1]
('lee',)
&gt;&gt;&gt; t[-2]
'lee'
&gt;&gt;&gt; t.remove("clemmer")

Traceback (most recent call last):
  File "&lt;pyshell#122&gt;", line 1, in &lt;module&gt;
    t.remove("clemmer")
AttributeError: 'tuple' object has no attribute 'remove'
&gt;&gt;&gt; t.pop()

Traceback (most recent call last):
  File "&lt;pyshell#123&gt;", line 1, in &lt;module&gt;
    t.pop()
AttributeError: 'tuple' object has no attribute 'pop'
&gt;&gt;&gt; t.append("albert")

Traceback (most recent call last):
  File "&lt;pyshell#124&gt;", line 1, in &lt;module&gt;
    t.append("albert")
AttributeError: 'tuple' object has no attribute 'append'
&gt;&gt;&gt; t.insert("albert")

Traceback (most recent call last):
  File "&lt;pyshell#126&gt;", line 1, in &lt;module&gt;
    t.insert("albert")
AttributeError: 'tuple' object has no attribute 'insert'</pre>
<p>As you can see, defining a tuple and calling an element thereof is very much like working with lists. However, trying to change it throws an exception.  Tuples have no methods.</p>
<p>Why use a tuple? It&#8217;s faster.  Therefore, <em>use tuples for constants that don&#8217;t change</em>.</p>
<p><em>Further reading on tuples:</em></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<ul>
<li><span style="font-style: normal;"><a title="&quot;Sorting tuples&quot; on the Python Knowledge Base" href="http://www.faqts.com/knowledge_base/view.phtml/aid/4553/fid/587">&#8220;Sorting tuples&#8221;</a> on the </span><span style="font-style: normal;"><a title="Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/199">Python Knowledge Base</a></span></li>
<li><span style="font-style: normal;"><a title="&quot;Tuples and Sequences&quot; in the Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/node7.html#SECTION007300000000000000000">&#8220;Tuples and Sequence&#8221;</a> in the <a title="Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/tut.html">Python Tutorial</a></span></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a name="variables"></a></p>
<h4>Declaring Variables</h4>
<p><a href="#top">Top</a></p>
<p>Python has local and global variables, but doesn&#8217;t explicitly declare variables.  A variable is created when you assign a value to it, and is destroyed once out of scope.  You cannot reference a variable that hasn&#8217;t been assigned a value (and hence doesn&#8217;t exist):</p>
<pre>&gt;&gt;&gt; myParams = { "firstname":"lee",
	     "lastname":"clemmer",
	     "age":"26"}
&gt;&gt;&gt; myParams
{'lastname': 'clemmer', 'age': '26', 'firstname': 'lee'}
&gt;&gt;&gt; x

Traceback (most recent call last):
  File "&lt;pyshell#7&gt;", line 1, in &lt;module&gt;
    x
NameError: name 'x' is not defined
&gt;&gt;&gt; x = 1
&gt;&gt;&gt; x
1</pre>
<p>When creating variables, you can <strong>assign multiple values</strong> to variables at once:</p>
<pre>&gt;&gt;&gt; numbers = (1,2,3)
&gt;&gt;&gt; numbers
(1, 2, 3)
&gt;&gt;&gt; (x,y,z) = numbers
&gt;&gt;&gt; x
1
&gt;&gt;&gt; y
2
&gt;&gt;&gt; z
3
&gt;&gt;&gt; (a,b,c,d) = numbers

Traceback (most recent call last):
  File "&lt;pyshell#16&gt;", line 1, in &lt;module&gt;
    (a,b,c,d) = numbers
ValueError: need more than 3 values to unpack</pre>
<p>As you can see by the last example, the number of variables have to match the number of elements in the tuple, list, or dictionary.  You can also assign variables using the <em>range</em> function:</p>
<pre>&gt;&gt;&gt; (one, two, three, four) = range(4)
&gt;&gt;&gt; one
0
&gt;&gt;&gt; two
1
&gt;&gt;&gt; three
2
&gt;&gt;&gt; four
3</pre>
<p>For more information on <em>range</em>:</p>
<pre>&gt;&gt;&gt; print range.__doc__
range([start,] stop[, step]) -&gt; list of integers

Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
These are exactly the valid indices for a list of 4 elements.
&gt;&gt;&gt; range(1,100,3)
[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52,
55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97]</pre>
<p><em>Further reading on variables:</em></p>
<ul>
<li><a title="&quot;Variables&quot; in &quot;How to Think Like a Computer Scientist: Learning With Python&quot;" href="http://openbookproject.net//thinkCSpy/ch02.xhtml#auto1">&#8220;Variables&#8221;</a> in <a title="&quot;How to Think Like a Computer Scientist: Learning With Python&quot;" href="http://www.openbookproject.net//thinkCSpy/">&#8220;How to Think Like a Computer Scientist: Learning With Python</a></li>
</ul>
<p><a name="strings"></a></p>
<h4>Formatting Strings</h4>
<p><a href="#top">Top</a></p>
<p>Python allows you to <strong>format values into strings</strong>, for example by using the string placeholder %s:</p>
<pre>&gt;&gt;&gt; x = "a string"
&gt;&gt;&gt; y = "another string"
&gt;&gt;&gt; <strong>"%s and %s" % (x,y)</strong>
'a string and another string'</pre>
<p>Importantly, <strong>the expression evaluates to a string</strong>.  This implies that you can coerce types into strings.</p>
<p>This kind of string formatting allows you to &#8220;join&#8221; a string and, say, a number, which you normally couldn&#8217;t concatenate:</p>
<pre>&gt;&gt;&gt; x = "you can concatenate "
&gt;&gt;&gt; y = "two strings"
&gt;&gt;&gt; print x + y
you can concatenate two strings
&gt;&gt;&gt; "%s%s like this also" % (x,y)
'you can concatenate two strings like this also'
&gt;&gt;&gt; number = 2
&gt;&gt;&gt; print x + number + " a string and number - not!"

Traceback (most recent call last):
  File "&lt;pyshell#15&gt;", line 1, in &lt;module&gt;
    print x + number + " a string and number - not!"
TypeError: cannot concatenate 'str' and 'int' objects
&gt;&gt;&gt; "%s%d different types like so - to make a string" % (x,number)
'you can concatenate 2 different types like so - to make a string'</pre>
<p>You can also work with <strong>floats</strong>:</p>
<pre>&gt;&gt;&gt; print "This is a float: <strong>%f</strong>" % 3.1425
This is a float: 3.142500
&gt;&gt;&gt; print "To control decimal places: <strong>%.2f</strong>" % 3.1425
To control decimal places: 3.14
&gt;&gt;&gt; print "How about a +/- sign: %<strong>+.2f</strong>" % -3.1425
How about a +/- sign: -3.14</pre>
<p><em>Further reading on formatting strings:</em></p>
<ul>
<li><em><a title="&quot;String Formatting Operations&quot; in the Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/typesseq-strings.html"><span style="font-style: normal;">&#8220;String Formatting Operations</span><span style="font-style: normal;">&#8220;</span></a><span style="font-style: normal;"> in the </span><span style="font-style: normal;"><a title="Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/lib.html">Python Library Reference</a></span></em></li>
</ul>
<h4>Joining Lists and Splitting Strings</h4>
<p>All strings are themselves objects, and as such have a built-in <strong>join()</strong> function.  The join function takes a list and joins its elements into a single string, separated by the string that made the join call:</p>
<pre>&gt;&gt;&gt; list
['Monday', 'Tuesday', 'Make sense?']
&gt;&gt;&gt; " is a day. ".<strong>join(list)</strong>
'Monday is a day. Tuesday is a day. Make sense?'</pre>
<p>You can also reverse this using split():</p>
<pre>&gt;&gt;&gt; sentences = " is a day. ".join(list)
&gt;&gt;&gt; sentences
'Monday is a day. Tuesday is a day. Make sense?'
&gt;&gt;&gt; sentences.<strong>split(" is a day. ")</strong>
['Monday', 'Tuesday', 'Make sense?']
&gt;&gt;&gt; list
['Monday', 'Tuesday', 'Make sense?']
&gt;&gt;&gt; sentences.split(" is a day. ", <strong>1</strong>)
['Monday', 'Tuesday is a day. Make sense?']</pre>
<p>The last example shows that split takes an optional argument, in this case how many times the split should occur.</p>
<p><em>Further reading on string methods:</em></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<ul>
<li><a title="Questions about strings on the Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/480"><span style="font-style: normal;">Questions about strings</span></a><span style="font-style: normal;"> and <a title="Sample string code on the Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/539">sample string code</a> on the </span><a title="Python Knowledge Base" href="http://www.faqts.com/knowledge_base/index.phtml/fid/199"><span style="font-style: normal;">Python Knowledge Base</span></a></li>
<li><a title="&quot;String Methods&quot; in the Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/string-methods.html"><span style="font-style: normal;">&#8220;String Methods&#8221;</span></a><span style="font-style: normal;"> and the <a title="string module in the Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/module-string.html">string module</a> in the </span><span style="font-style: normal;"><a title="Python Library Reference" href="http://www.python.org/doc/2.5.2/lib/lib.html">Python Library Reference</a></span></li>
<li><span style="font-style: normal;"><a class="toc-backref" href="http://www.python.org/doc/faq/general/#id38">Why is join() a string method instead of a list or tuple method?</a> on <a title="Python FAQ" href="http://www.python.org/doc/faq/">Python FAQ</a></span></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="#top">Top</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/04/chapter-3-notes-on-dive-into-python-by-mark-pilgrim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chapter 2: Notes on &#8220;Dive Into Python&#8221; by Mark Pilgrim</title>
		<link>http://www.leeclemmer.com/2009/04/chapter-notes-on-dive-into-python-by-mark-pilgrim/</link>
		<comments>http://www.leeclemmer.com/2009/04/chapter-notes-on-dive-into-python-by-mark-pilgrim/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 15:07:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[doc string]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[indentation]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[objects]]></category>

		<guid isPermaLink="false">http://leeclemmer.com/?p=10</guid>
		<description><![CDATA[Note: I’m currently in the process of learning Python.  These are notes on &#8220;Dive Into Python&#8221; by Mark Pilgrim (also available online), an excellent book if you&#8217;re like me and learn by the &#8220;do first, understand later&#8221; method. Declaring functions def functionName(params): Defining a function&#8217;s doc string def functionName(params): """This is the explanation of the function, surrounded by triple [...]]]></description>
			<content:encoded><![CDATA[<div>
<p><em>Note: I’m currently in the process of learning Python.  These are notes on <a href="http://www.amazon.com/gp/product/1590593561?ie=UTF8&amp;tag=drinbl-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1590593561">&#8220;Dive Into Python&#8221;</a><img src="http://www.assoc-amazon.com/e/ir?t=drinbl-20&amp;l=as2&amp;o=1&amp;a=1590593561" alt="" width="1" height="1" border="0" /> by Mark Pilgrim (also available <a title="Dive Into Python" href="http://diveintopython.org/">online</a>), an excellent book if you&#8217;re like me and learn by the &#8220;do first, understand later&#8221; method.<br />
</em></p>
</div>
<h4>Declaring functions</h4>
<pre>def functionName(params):</pre>
<h4>Defining a function&#8217;s doc string</h4>
<pre>def functionName(params):
   """This is the explanation of the function, surrounded by triple quotes.
   Returns a string."""</pre>
<p><em>Further reading on document strings:</em></p>
<ul>
<li><a title="Python Enhancement Proposals (PEP) 257: Docstring Conventions" href="http://www.python.org/dev/peps/pep-0257/">Python Enhancement Proposals (PEP) 257: Docstring Conventions</a></li>
<li><a title="http://www.python.org/dev/peps/pep-0008/" href="Style Guide for Python Code">PEP 8: Style Guide for Python Code</a></li>
<li><a title="Documentation Strings in Python Tutorial" href="http://www.python.org/doc/2.5.2/tut/node6.html#SECTION006760000000000000000">Documentation Strings</a> in <a title="Python Tutorial (2.5.2)" href="http://www.python.org/doc/2.5.2/tut/tut.html">Python Tutorial (2.5.2)</a></li>
</ul>
<p><span id="more-10"></span></p>
<h4>Import search path</h4>
<p>When importing a module, python looks in several places as defined in <strong>sys.path</strong>:</p>
<pre>&gt;&gt;&gt; import sys
&gt;&gt;&gt; sys.path
['C:\Python25\Lib\idlelib', 'C:\Python25\lib\site-packages\setuptools-0.6c7-py2.5.egg',
'C:\WINDOWS\system32\python25.zip', 'C:\Python25\DLLs', 'C:\Python25\lib',
'C:\Python25\lib\plat-win', 'C:\Python25\lib\lib-tk', 'C:\Python25',
'C:\Python25\lib\site-packages']
&gt;&gt;&gt; sys
&lt;module 'sys' (built-in)&gt;
&gt;&gt;&gt; sys.path.append('/my/new/path')</pre>
<p>The last line illustrates how to add a path to look in.</p>
<h4>Everything is an object</h4>
<p>Everything is an object! Functions, modules, strings, lists, everything!  Python objects are objects in the sense that they can be passed as an argument to a function or be assigned to variables.</p>
<p>As an example, all functions have a built-in attribute called __doc__, which you can access like this:</p>
<pre>&gt;&gt;&gt; print importedModule.functionName.__doc__
This is the explanation of the function, surrounded by triple quotes.
Returns a string.</pre>
<p><em>Further reading on objects:</em></p>
<ul>
<li><a title="&quot;Objects, values, and types&quot; in the Python Reference Manual" href="http://www.python.org/doc/2.5.2/ref/objects.html">&#8220;Objects, values, and types&#8221;</a> in the <a title="Python Reference Manual" href="http://www.python.org/doc/2.5.2/ref/ref.html">Python Reference Manual</a></li>
<li><a title="&quot;Python Objects&quot; on effbot.org" href="http://effbot.org/zone/python-objects.htm">&#8220;Python Objects&#8221;</a> on effbot.org</li>
</ul>
<h4>Indenting code</h4>
<p>As a newbie to Python, the built-in syntax rules are particularly appealing to me.</p>
<p>There are no braces for functions, no semicolons to end a line; simply indent and a code block is defined (for if statements, functions, etc.).  The only delimiter here is the colon&#8221;:&#8221;.</p>
<p><em>Further reading on indenting code:</em></p>
<ul>
<li><a title="&quot;Indentation&quot; in the Python Reference Manual" href="http://python.org/doc/2.5.2/ref/indentation.html">&#8220;Indentation&#8221;</a> in the <a title="Python Reference Manual" href="http://www.python.org/doc/2.5.2/ref/ref.html">Python Reference Manual</a></li>
<li><a title="http://www.python.org/dev/peps/pep-0008/" href="Style Guide for Python Code">PEP 8: Style Guide for Python Code</a></li>
</ul>
<h4>Testing modules with if __name__</h4>
<p>All modules have a built-in attribute __name__.  The value of this attribute depends on how the module is being used; is it imported or run on its own?</p>
<ul>
<li>If the module is imported, __name__ equals the filename (without path, without file extension)</li>
<li>If the module is run as a stand-alone program, the value of __name__ is a special default value, __main__</li>
</ul>
<p>Why is this important? <strong>It means that you can embed a test suite in the module itself.</strong>  In other words, it&#8217;s code that will only execute when running the module directly, not when it&#8217;s being imported.  To do this, you would include the following in the module:</p>
<pre>if __name__ == "__main__":
    """Insert test code here."""</pre>
<p><em>Further reading on importing modules:</em></p>
<ul>
<li><a title="&quot;The import statement&quot; in the Python Reference Manual" href="http://www.python.org/doc/2.5.2/ref/import.html">&#8220;The import statement&#8221;</a> in the <a title="Python Reference Manual" href="http://www.python.org/doc/2.5.2/ref/ref.html">Python Reference Manual</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.leeclemmer.com/2009/04/chapter-notes-on-dive-into-python-by-mark-pilgrim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

