<?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>FND's Blag &#187; Python</title>
	<atom:link href="http://fnd.lewcid.org/blog/archive/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://fnd.lewcid.org/blog</link>
	<description>Just Another Personal Wobsite</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:19:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Python virtual namespaces</title>
		<link>http://fnd.lewcid.org/blog/archive/129</link>
		<comments>http://fnd.lewcid.org/blog/archive/129#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:37:02 +0000</pubDate>
		<dc:creator>FND</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[TiddlyWeb]]></category>

		<guid isPermaLink="false">http://fnd.lewcid.org/blog/?p=129</guid>
		<description><![CDATA[Recently we&#8217;ve started adding TiddlyWeb plugins to a virtual namespace. Holger (of py.test fame) was interested in this technique, so I posted my experience to the py-dev mailing list &#8212; which I figured was worth copying here: The goal is to use a common package name (here: &#8220;foo&#8221;) for multiple independent modules or packages (&#8220;alpha&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we&#8217;ve started adding <a href="http://tiddlyweb.com">TiddlyWeb</a> <a href="http://pypi.python.org/pypi?%3Aaction=search&#038;term=tiddlywebplugins">plugins</a> to a <a href="http://cdent.tumblr.com/post/216241761/python-namespace-packages-for-tiddlyweb">virtual namespace</a>.</p>
<p><a href="http://tetamap.wordpress.com">Holger</a> (of <a href="http://codespeak.net/py/dist/">py.test</a> fame) was interested in this technique, so I <a href="http://codespeak.net/pipermail/py-dev/2009q4/001305.html">posted</a> my experience to the py-dev mailing list &mdash; which I figured was worth copying here:<br />
<span id="more-129"></span></p>
<blockquote><p>
The goal is to use a common package name (here: &#8220;foo&#8221;) for multiple independent modules or packages (&#8220;alpha&#8221; and &#8220;bravo&#8221; &#8211; to be accessed as <code>foo.alpha</code> and <code>foo.bravo</code>, respectively).</p>
<p>It&#8217;s actually rather simple:<br />
The individual components must be contained in a directory named after the virtual namespace, with an <code>__init__.py</code> containing nothing but the following statement:<br />
<code>__import__("pkg_resources").declare_namespace(__name__)</code><br />
To make Python aware of the local package (e.g. for running tests out of the repository), something like the following is required in a root-level <code>__init__.py</code>:<br />
<code>path = os.path.abspath(VIRTUAL_NAMESPACE)<br />
sys.modules[VIRTUAL_NAMESPACE].__dict__["__path__"].insert(0, path)</code><br />
This is illustrated here:<br />
     <a href="http://gist.github.com/231862">http://gist.github.com/231862</a></p>
<p>Disclaimer: I&#8217;m far from being an expert, just sharing what we&#8217;ve learned so far (it&#8217;s an ongoing effort).
</p></blockquote>
<p>While there are <a href="http://www.python.org/dev/peps/pep-0382/">other options</a>, this currently appears to be the most compatible approach (as confirmed by <a href="http://tarekziade.wordpress.com">Tarek</a>).</p>
<p><strong>Update:</strong> Some further insights made me <a href="http://github.com/FND/tiddlyweb-plugins/commit/f1f7069ee1731bbf6f6c240ee2e2a6b2d81f4dca">tweak the approach to module-path mangling</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://fnd.lewcid.org/blog/archive/129/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where Python Sucks</title>
		<link>http://fnd.lewcid.org/blog/archive/92</link>
		<comments>http://fnd.lewcid.org/blog/archive/92#comments</comments>
		<pubDate>Sun, 05 Jul 2009 09:32:42 +0000</pubDate>
		<dc:creator>FND</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[EuroPython]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://fnd.lewcid.org/blog/?p=92</guid>
		<description><![CDATA[More raw notes from EuroPython 2009 &#8211; this time from the entertaining and informative Python Sucks[1] session: programming languages do matter; choice can hugely affect the end result whitespace enforcement the &#8220;best worst feature&#8221; (other languages&#8217; worst features are much more severe) Unicode handling is a pain lambdas should just be called functions (increases acceptance) [...]]]></description>
			<content:encoded><![CDATA[<p>More <a href="http://fnd.lewcid.org/blog/archive/80">raw notes</a> from <a href="http://wiki.europython.eu/After">EuroPython 2009</a> &#8211; this time from the entertaining and informative <a href="http://www.europython.eu/talks/talk_abstracts/index.html#talk21">Python Sucks</a><sup>[1]</sup> session:<br />
<span id="more-92"></span></p>
<ul>
<li>programming languages <em>do</em> matter; choice can hugely affect the end result</li>
<li>whitespace enforcement the &#8220;best worst feature&#8221; (other languages&#8217; worst features are much more severe)</li>
<li>Unicode handling is a pain</li>
<li>lambdas
<ul>
<li>should just be called functions (increases acceptance)</li>
<li>cannot contain statements</li>
<li>binding issues in loops</li>
</ul>
</li>
<li>threading is haphazard (GIL is evil) &mdash; however: CPython <em>implementation</em> issue, addressed in v2.6 &#8211; &#8220;it&#8217;s <em>different</em>, not necessarily insufficient (e.g. using underlying OS)&#8221;</li>
<li>confusing packaging situation (setuptools, Easy Install, distutils, eggs, buildout, PyPI, virtualenv) &#8211; &#8220;solved, but people disagree&#8221; &#8211; &#8220;Easy Install sucks, too magic&#8221; &#8211; &#8220;not a Python-specific, but OS-level task&#8221; &#8211; problem is hard to solve, as there&#8217;s a variety of different usage scenarios</li>
<li>infinity, NaN support (<a href="http://en.wikipedia.org/wiki/IEEE_floating-point">IEEE 754</a>)</li>
<li>floating point printing (0.1 becomes 0.10000000000000001) &mdash; fixed in v3.1</li>
<li>division &mdash; fixed in v3.0</li>
<li>decorators (&#8220;<code>@</code> is scary, unfamiliar syntax&#8221;)</li>
<li>argument list splicing (e.g. <code>zip(*l)</code>) &#8211; &#8220;unfamiliar syntax&#8221;</li>
<li>some modules only exist on certain platforms</li>
<li>positive aspects
<ul>
<li>everything is an object</li>
<li>object instantiation (no <code>new</code> keyword &#8211; i.e. just like calling a function)</li>
<li>generator expressions (from Haskell)</li>
<li>chained comparisons (<code>0 < = x < n</code>) - though largely unknown, and allows </code><code>0 < x > a</code> or <code>0 < x in L</code></code></li>
<li>Iverson&#8217;s convention (<code>x < y</code> evaluates to 0/False or 1/True) - "open to abuse"</code></li>
<li>access control (public, private etc.) &#8211; not enforced (&#8220;advisory [bicycle] locks&#8221;) &#8211; likely more a social than a technical problem</li>
<li>fractions (from v2.6)</li>
<li>power (<code>x**2</code>)</li>
<li>explicit > implicit (unlike <code>this</code> in JavaScript, for example)</li>
</ul>
</li>
<li>&#8220;Python sucks because sometimes it has to run on Windows&#8221;</li>
</ul>
<p><a href="http://wiki.europython.eu/TalkMaterials">slides available</a></p>
<p>Obviously some points were quite controversial (whitespace FTW!) &#8211; which is what made the session so interesting.</p>
<ol class="footnotes"><li id="footnote_0_92" class="footnote">retitled <i>What Sucks About Python</i> in the official program</li></ol>]]></content:encoded>
			<wfw:commentRss>http://fnd.lewcid.org/blog/archive/92/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rapid Testing with py.test</title>
		<link>http://fnd.lewcid.org/blog/archive/80</link>
		<comments>http://fnd.lewcid.org/blog/archive/80#comments</comments>
		<pubDate>Mon, 29 Jun 2009 20:56:36 +0000</pubDate>
		<dc:creator>FND</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[EuroPython]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://fnd.lewcid.org/blog/?p=80</guid>
		<description><![CDATA[Somewhat unexpectedly, I attended a tutorial on py.test at EuroPython today &#8212; which turned out to be very useful. Below are my raw (i.e. imperfect and likely inadequate) notes from that session. minimal, no-API approach; no need for boilerplates however, a lot of optional framework-y functionality is provided convention over configuration (automatic discovery of test_*.py, [...]]]></description>
			<content:encoded><![CDATA[<p>Somewhat <a href="http://twitter.com/FND/status/2385511283">unexpectedly</a>, I attended a tutorial on <a href="http://pytest.org">py.test</a> at EuroPython today &mdash; which turned out to be <a href="http://twitter.com/FND/status/2387884483">very useful</a>.<br />
<span id="more-80"></span><br />
Below are my raw (i.e. imperfect and likely inadequate) notes from that session.</p>
<ul>
<li>
		minimal, no-API approach; no need for boilerplates<br />
		however, a lot of optional framework-y functionality is provided
	</li>
<li>convention over configuration (automatic discovery of <code>test_*.py</code>, <code>def test_*</code>, <code>class Test*</code>)</li>
<li><i>py.test</i> overrides <code>AssertionError</code> built-in, then re-runs statement to provide details &mdash; avoid assertions with side-effects!</li>
<li>skip tests only for platform and dependency issues; use <code>@py.test.mark.xfail</code> for &#8220;expected to fail&#8221;</li>
<li><i>funcargs</i> introduced in v1.0 to replace traditional setup methods for fixtures (user &#038; provider, loose coupling); allows for more flexible grouping</li>
<li><code>print</code> captured by default, only shown on failure</li>
<li>internally makes use of its own hook architecture (i.e. many features implemented as plugins)</li>
<li><code>yield</code>ed tests are deprecated (due to internal ambiguity); recommended to use <code>pytest_generate_tests</code> instead</li>
<li>interesting <a href="http://codespeak.net/svn/py/trunk/py/test/plugin/">plugins</a>: coverage and PyLint integration</li>
<li>can be used to run non-Python tests (e.g. <a href="http://bitbucket.org/pedronis/js-infrastructure/">for JavaScript</a>)</li>
<li>supports distributed testing (load balancing with multiple CPUs or remote machines, testing on multiple platforms)</li>
<li>might be renamed (&#8220;I wish I&#8217;d named it differently&#8221;)</li>
</ul>
<p><a href="http://tetamap.wordpress.com">Holger Krekel</a> has also published his <a href="http://codespeak.net/~hpk/rapid-testing.pdf">slides</a> (PDF), which are well worth a look.</p>
]]></content:encoded>
			<wfw:commentRss>http://fnd.lewcid.org/blog/archive/80/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
