<?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>Adam Loving&#039;s Blog &#187; Programming</title>
	<atom:link href="http://adamloving.com/tag/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://adamloving.com</link>
	<description>Seattle Social Web Development</description>
	<lastBuildDate>Fri, 20 Jan 2012 18:07:49 +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>Ruby boolean operator (or ruby parsing) bug</title>
		<link>http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug</link>
		<comments>http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug#comments</comments>
		<pubDate>Wed, 09 Jul 2008 22:33:39 +0000</pubDate>
		<dc:creator>Adam Loving</dc:creator>
				<category><![CDATA[Projects, Programming, Technology]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://adamloving.com/?p=399</guid>
		<description><![CDATA[This has bitten me a couple times in the last few days. The Ruby &#8220;or&#8221; (or equals) operator appears to have a bug where, when used in an assignment, the first value is assigned rather than the results of the entire expression. irb(main):001:0&#62; x = false &#124;&#124; true =&#62; true irb(main):002:0&#62; x =&#62; true irb(main):003:0&#62; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This has bitten me a couple times in the last few days. The Ruby &#8220;or&#8221; (or equals) operator appears to have a bug where, when used in an assignment, the first value is assigned rather than the results of the entire expression.</p>
<p>irb(main):001:0&gt; x = false || true<br />
=&gt; true<br />
irb(main):002:0&gt; x<br />
=&gt; true<br />
irb(main):003:0&gt; z = false or true<br />
=&gt; true<br />
irb(main):004:0&gt; z<br />
=&gt; <strong>false</strong></p>
<p>ruby version: ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]</p>
<p>I would expect z to be true in that last example.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/a23916fc-a6d1-4a9c-9e5d-806cbfccece6/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=a23916fc-a6d1-4a9c-9e5d-806cbfccece6" alt="Zemanta Pixie" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python Path and Module Basics</title>
		<link>http://adamloving.com/internet-programming/python-paths-and-modules</link>
		<comments>http://adamloving.com/internet-programming/python-paths-and-modules#comments</comments>
		<pubDate>Thu, 19 Jun 2008 21:39:54 +0000</pubDate>
		<dc:creator>Adam Loving</dc:creator>
				<category><![CDATA[Projects, Programming, Technology]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://adamloving.com/?p=293</guid>
		<description><![CDATA[I&#8217;m getting started with Python and Google App Engine. One of the first things I had to figure out was how Python handles paths and module names. You can see what paths python is looking on with this command sequence:   $ python ['', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python25.zip', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/plat-darwin', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/plat-mac', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/plat-mac/lib-scriptpackages', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/lib-tk', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/lib-dynload', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/site-packages'] Python 2.5.2 (r252:60911, [...]]]></description>
			<content:encoded><![CDATA[<p></p><div>I&#8217;m getting started with Python and Google App Engine. One of the first things I had to figure out was how Python handles paths and module names.</div>
<div>You can see what paths python is looking on with this command sequence:</div>
<div>
<div>
<p align="left"> </p>
<pre>$ python</pre>
<pre>['', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python25.zip', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/plat-darwin', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/plat-mac', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/plat-mac/lib-scriptpackages', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/lib-tk', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/lib-dynload', '/opt/local/var/macports/software/python25/2.5.2_2+darwin_8/opt/local/lib/python2.5/site-packages']</pre>
</div>
<div>
<pre>Python 2.5.2 (r252:60911, Jun  1 2008, 16:53:35)</pre>
</div>
<div>
<pre>[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin</pre>
</div>
<div>
<pre>Type "help", "copyright", "credits" or "license" for more information.</pre>
</div>
<div>
<pre>&gt;&gt;&gt; import sys</pre>
</div>
<div>
<pre>&gt;&gt;&gt; sys.path</pre>
</div>
</div>
<div>
<pre>&gt;&gt;&gt; exit()</pre>
</div>
<p align="left"> </p>
<div>Inside a python script Modules are included with this syntax:</div>
<pre>from google.appengine.ext.bulkload import constants</pre>
<div>All that means is that python is going to look on the paths above for /google/appengine/ext/bulkload/constants.py</div>
<div>In my case, the script I was trying to run sets up the paths for a secondary main script with some code like this:</div>
<p align="left"> </p>
<div>
<pre>EXTRA_PATHS = [</pre>
</div>
<div>
<pre>DIR_PATH,</pre>
</div>
<div>
<pre>os.path.join(GOOGLE_PATH, 'lib', 'django'),</pre>
</div>
<div>
<pre>os.path.join(GOOGLE_PATH, 'lib', 'webob'),</pre>
</div>
<div>
<pre>os.path.join(GOOGLE_PATH, 'lib', 'yaml', 'lib'),</pre>
</div>
<div>
<pre>]</pre>
</div>
<div>
<pre>if __name__ == '__main__':</pre>
</div>
<div>
<pre>sys.path = EXTRA_PATHS + sys.path</pre>
</div>
<div>
<pre>script_path = os.path.join(DIR_PATH, BULKLOAD_CLIENT_PATH)</pre>
</div>
<div>
<pre>execfile(script_path, globals())</pre>
</div>
<p align="left"> </p>
<div>So, you can see here that sys.path is assignable and retained when calling other scripts.</div>
<div>I also learned that you can set the $PYTHONPATH environment variable to a list of paths, just like the normal $PATH variable. However, unlike Windows, you have &#8220;export&#8221; the environment variable.</div>
<p align="left">&nbsp;</p>
<div>
<pre>$ PYTHONPATH=$PYTHONPATH:/include/this:/and/this</pre>
</div>
<div>
<pre>export $PYTHONPATH</pre>
</div>
<p align="left"> </p>
<div>The export command takes the local shell variable and makes it visible as a global variable (in this case to Python).</div>
]]></content:encoded>
			<wfw:commentRss>http://adamloving.com/internet-programming/python-paths-and-modules/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

