<?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>Zach Dwiel &#187; python</title>
	<atom:link href="http://dwiel.net/blog/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://dwiel.net</link>
	<description>Repository of code snippits and ideas</description>
	<lastBuildDate>Thu, 22 Apr 2010 15:15:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Script to center the current window (linux)</title>
		<link>http://dwiel.net/blog/script-to-center-the-current-window-linux/</link>
		<comments>http://dwiel.net/blog/script-to-center-the-current-window-linux/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 02:49:05 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[script]]></category>
		<category><![CDATA[desktop]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wmctrl]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=55</guid>
		<description><![CDATA[Just remembered that I hadn't published this script that I use fairly often which centers the currently active window on the screen using wmctrl (requires the patch provided)
wmctrl-patch
center_active_window.py
]]></description>
			<content:encoded><![CDATA[<p>Just remembered that I hadn't published this script that I use fairly often which centers the currently active window on the screen using wmctrl (requires the patch provided)</p>
<p><a href="http://dwiel.net/wp-content/uploads/2008/11/wmctrl.diffs">wmctrl-patch</a></p>
<p><a href="http://dwiel.net/wp-content/uploads/2008/11/center_active_window.py">center_active_window.py</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/script-to-center-the-current-window-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List of bound variables in Python (excluding variables from modules)</title>
		<link>http://dwiel.net/blog/list-of-bound-variables-in-python-excluding-variables-from-modules/</link>
		<comments>http://dwiel.net/blog/list-of-bound-variables-in-python-excluding-variables-from-modules/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 05:40:08 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=38</guid>
		<description><![CDATA[I've heard multiple people ask for a way to see a list of locally bound variables in python.  It would be especially useful for use in the interactive prompt.  They like the interface that matlab gave them and this is one of the features they miss the most.  I'm not sure what the best [...]]]></description>
			<content:encoded><![CDATA[<p>I've heard multiple people ask for a way to see a list of locally bound variables in python.  It would be especially useful for use in the interactive prompt.  They like the interface that matlab gave them and this is one of the features they miss the most.  I'm not sure what the best way to accomplish this is, but I've coded together one solution.  Here is an example use case:</p>
<pre class="python">&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> boundvars <span style="color: #ff7700;font-weight:bold;">import</span> boundvars
<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> :
         a = <span style="color: #ff4500;">1</span>
         b = <span style="color: #ff4500;">2</span>
         <span style="color: #ff7700;font-weight:bold;">assert</span> boundvars<span style="color: black;">&#40;</span><span style="color: #008000;">vars</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> == <span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>: <span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'b'</span>: <span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span>
         <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span>
         <span style="color: #ff7700;font-weight:bold;">assert</span> boundvars<span style="color: black;">&#40;</span><span style="color: #008000;">vars</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> == <span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>: <span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'b'</span>: <span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span>
&nbsp;
x = <span style="color: #ff4500;">1</span>
y = <span style="color: #ff4500;">2</span>
boundvars<span style="color: black;">&#40;</span><span style="color: #008000;">vars</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
= <span style="color: black;">&#123;</span><span style="color: #483d8b;">'y'</span>: <span style="color: #ff4500;">2</span>, <span style="color: #483d8b;">'x'</span>: <span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'test'</span>: &lt;function <span style="color: #dc143c;">test</span> at 0x0000&gt;<span style="color: black;">&#125;</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">urllib</span> <span style="color: #ff7700;font-weight:bold;">import</span> *
boundvars<span style="color: black;">&#40;</span><span style="color: #008000;">vars</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
= <span style="color: black;">&#123;</span><span style="color: #483d8b;">'x'</span>: <span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'y'</span>: <span style="color: #ff4500;">2</span>, <span style="color: #483d8b;">'test'</span> : &lt;function <span style="color: #dc143c;">test</span> at 0x0000&gt;<span style="color: black;">&#125;</span>
&nbsp;
<span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;</pre>
<p>As you can see, boundvars is called with vars() as a parameter which then returns a dictionary of locally bound variables.  If boundvars.ignore_external_functions is set to False, the first two calls which show x and y bound would also show the variable boundvars.  If it is set to True, then all values which are functions not defined in the __main__  module are excluded from the output dictionary.  The latest code can be downloaded below.  Installation is as simple as:<br />
<code><br />
$ wget http://dwiel.net/wp-content/uploads/2008/10/boundvars.tar.gz<br />
$ tar -xvf boundvars.tar.gz<br />
$ cd boundvars<br />
$ sudo python setup.py install<br />
</code></p>
<p>Its not big enough to warrant a project at a code hosting service so its just provided here.  If you know of any way that this module could be improved (or avoided by some cool function I don't know about) please, let me know!</p>
<p><a href="http://dwiel.net/wp-content/uploads/2008/10/boundvars.tar.gz">boundvars.tar.gz</a> (version 0.1)</p>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/list-of-bound-variables-in-python-excluding-variables-from-modules/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
