<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Matt Harrison&apos;s blog</title><link>http://panela.blog-city.com/</link><description>Discussion of python, open source, linux, wiimotes, development, ajax, etc.</description><copyright>Copyright 2009 panela.blog-city.com</copyright><generator>Matt Harrison</generator><lastBuildDate>Thu, 05 Nov 2009 15:25:00 GMT</lastBuildDate><image><title>Matt Harrison&apos;s blog</title><url>http://server1.blog-city.com/images/bc_v5_logo_small.gif</url><link>http://panela.blog-city.com/</link></image><ttl>360</ttl><docs>http://backend.userland.com/rss</docs><item><title>11 essentials commands for a tiling window manager</title><guid isPermaLink="true">http://panela.blog-city.com/11_essentials_commands_for_a_tiling_window_manager.htm</guid><link>http://panela.blog-city.com/11_essentials_commands_for_a_tiling_window_manager.htm</link><pubDate>Mon, 26 Oct 2009 14:21:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=11%5Fessentials%5Fcommands%5Ffor%5Fa%5Ftiling%5Fwindow%5Fmanager</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>I'm a visual person.  A nice chart or graph somehow fits my brain better than lots of text.  Here's an image I wish I had when I first installed <a href="http://awesome.naquadah.org/">awesome</a>.  I wish I had it a few weeks back when asked about tiling window managers at <a href="http://2009.utosc.com/">UTOSC</a>.  Now I'm thinking about giving the latest version of <a href="http://www.xmonad.org/">xmonad</a> a try (maybe I'll make an xmonad version).  (And if I had more time, I'd hack on the Python tiling wm, <a href="http://www.qtile.org/">qtile</a>).</p>
<center><img src='http://files.blog-city.com/files/F05/96843/p/f/awesomecheat.png' title='awesomecheat.png'/></center>
<p>This covers the default configuration for awesome.  And really that's about all you need to know.  Once you know how to start a terminal, and kill clients, the other basic commands are for navigation and changing layout/float/maximize.</p>
<p>So if you've been thinking about trying tiling wm's, give the recent awesome 3.4 a try.  Your hands and wrists might thank you.</p>]]></description><category>qtile</category><category>awesome</category><category>xmonad</category></item><item><title>Great post about what to do in Python module scope</title><guid isPermaLink="true">http://panela.blog-city.com/great_post_about_what_to_do_in_python_module_scope.htm</guid><link>http://panela.blog-city.com/great_post_about_what_to_do_in_python_module_scope.htm</link><pubDate>Mon, 19 Oct 2009 14:51:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=great%5Fpost%5Fabout%5Fwhat%5Fto%5Fdo%5Fin%5Fpython%5Fmodule%5Fscope</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p><a href="http://plope.com/Members/chrism/import_time_side_effects">Chris McDonough clearly explains what code is appropriate at the module level</a>.  In the spirit of "importing code shouldn't have weird side effects", here's his list:</p>
<ul>
<li>An import of another module or global.
<li>Assignment of a variable name in the module to some constant value.
<li>The addition of a function via a def statement.
<li>The addition of a class via a class statement.
<li>Control flow which may handles conditionals for platform-specific handling or failure handling of the above.
</ul>
<p>And then this great quote: <em>Any other sort of logic inside the top level execution path of a Python module (any code that would be executed during "import") should be regarded with great suspicion and perhaps even loathing.</em></p>
<p>Here here Chris!  Perhaps you should start a Foundation, Crusaders against Suspicious (Python) code.<p>
<p>(I guess this is sort of a retweet, since I didn't want to login to comment)  </p>]]></description></item><item><title>UTOS 2009 Review</title><guid isPermaLink="true">http://panela.blog-city.com/utos_2009_review_1.htm</guid><link>http://panela.blog-city.com/utos_2009_review_1.htm</link><pubDate>Mon, 12 Oct 2009 16:12:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=utos%5F2009%5Freview%5F1</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>I had a good time at UTOS.  The first day was mostly spent in my Intermediate Python workshop.  For those who attended I apologize for not having a break!  2.5 hours is a long time to listen to me spout off.  I think the workshop went well though.  We discussed testing (unittest/doctest), functional programming, functions, decorators, iterations, list comprehensions and generators.  After the speaking was the hands on portion.  The room was packed for the first part (some people stood for most of the time).  For the next hour or so people stayed around and hacked on python.  It was really cool to see people who had "only written 3 python programs", write a generator and understand what is happening.</p>
<p>That night we had a Utah Python group meeting.  Stephen McQuay did a great job of introducing Python.  One interesting fact, is that he said the main impetus for him learning python was the <a href="http://xkcd.com/353/">"import antigravity" xkcd cartoon</a>.  I've never heard that one before!</p>
<p>I also talked about coverage and that went well.  I had a little technical glitch at the start as OOo seemed to have problems with the projector.  (I've never seen it before but my presentation would open just fine when the projector was not plugged but would hang when it was.  Very weird and frustrating.  I finally opened OOo and then connected the projector and it worked.  For my workshop I made pdf backups of my preso in case this happened, but didn't bother for this since I had no problem the with the workshop preso.  Live and learn.  Always make a pdf backup on a thumbdrive!)</p>
<p>The other sessions I attended were pretty good.  One note, when you are demoing on a console there are two problems.  One is font size.  The other is that terminals show the input at the bottom of the screen (unless you are ctrl-l'ing all day long), which can be hard to see unless the screen is pretty high.  A tool like <a href="http://github.com/mattharrison/pykeyview">pykeyview</a> can go a long way towards helping with the latter problem (which came up in 2 sessions I attended).</p>]]></description><category>utos</category><category>xkcd</category><category>pykeyview</category></item><item><title>Looking for iphone beta testers</title><guid isPermaLink="true">http://panela.blog-city.com/looking_for_iphone_beta_testers.htm</guid><link>http://panela.blog-city.com/looking_for_iphone_beta_testers.htm</link><pubDate>Thu, 08 Oct 2009 06:13:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=looking%5Ffor%5Fiphone%5Fbeta%5Ftesters</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>My brother has a pretty cool iphone game in the works.  If anyone is <a href="http://blog.insightvr.com/?p=148">interested in beta testing and providing feedback, please get in touch with him!</p>]]></description><category>iphone</category><category>beta</category><category>3d</category><category>game</category></item><item><title>Cheatsheets/Handouts/Slides for Intermediate Python (and Testing)</title><guid isPermaLink="true">http://panela.blog-city.com/cheatsheetshandoutsslides_for_intermediate_python_and_tes.htm</guid><link>http://panela.blog-city.com/cheatsheetshandoutsslides_for_intermediate_python_and_tes.htm</link><pubDate>Thu, 08 Oct 2009 06:06:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=cheatsheetshandoutsslides%5Ffor%5Fintermediate%5Fpython%5Fand%5Ftes</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>Tomorrow I'm giving <a href="http://2009.utosc.com/presentation/119/">a workshop on Intermediate Python at the UTOS</a>.  In the session I'll discuss testing with the unittest and doctest modules for Python.  Then I discuss a bunch of what I consider to be intermediate Python constructs.  Included are decorators, list comprehensions, generators, generator expressions, functional constructs and function arguments.  Included when possible are explanations of why stuff works (such as generators and decorators) rather than just throwing out examples.  Hopefully the theory helps with understanding how to apply this knowledge later.</p>
<center><a href="http://attend.utosc.com"><img src="http://dl.utosc.com/09/badges/utosc2009_Speaker.png" /></a></center>
<p>One might wonder why I'm bundling testing in with the talk?  I guess it's excusable for beginners to neglect testing ;)</p>
<p>I created two handouts (generated with rst2odt) for the workshop, one on testing and another on the intermediate stuff.  I've also generated my slides (via rst2odp of course). <a href='http://files.blog-city.com/files/F05/96843/b/intermediatepython.tar.gz'>A tarball containing said materials is here.</a></p> 
<p>Are people interested in handouts/cheatsheets?  Should I throw the source up to <a href="http://github.com/mattharrison">github</a> if anyone wants to collaborate?</p>]]></description><category>python</category><category>rst2odp</category><category>testing</category><category>intermediate</category><category>list comprehension</category><category>generator</category><category>decorator</category></item><item><title>PyCon rst2odp offer</title><guid isPermaLink="true">http://panela.blog-city.com/pycon_rst2odp_offer.htm</guid><link>http://panela.blog-city.com/pycon_rst2odp_offer.htm</link><pubDate>Wed, 23 Sep 2009 17:22:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=pycon%5Frst2odp%5Foffer</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>If anyone is considering using rst2s5, please give rst2odp (odp is the format that OOo uses) a try.  If your slides work on rst2s5 but not on rst2odp, let me know and I'll try to address that.  I've been using it for a while now, but I got some feedback that others have had issues, so I'd like to address those.</p>
<p>Why rst2odp?  Template support, console presenter mode (supports presenter only notes), export to pdf/html/ppt, great fonts, no reloading firefox, tweak final output in OOo (though I never do this), beautiful code highlighting (via pygments).  <a href='http://assets.en.oreilly.com/1/event/27/Best%20practices%20for%20%27scripting%27%20with%20Python%203%20Presentation%201.pdf'>Here's a sample of rst2odp output (exported to pdf)</a>.</p>
<p>ps - Preliminary table support just landed in svn!</p>]]></description><category>rst2s5</category><category>rst2odp</category><category>ooo</category></item><item><title>Python and emacs (6): (exuberant) tags and Python</title><guid isPermaLink="true">http://panela.blog-city.com/python_and_emacs_6_exuberant_tags_and_python.htm</guid><link>http://panela.blog-city.com/python_and_emacs_6_exuberant_tags_and_python.htm</link><pubDate>Wed, 16 Sep 2009 05:39:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=python%5Fand%5Femacs%5F6%5Fexuberant%5Ftags%5Fand%5Fpython</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>Since ctags is somewhat language agnostic, this isn't really Python specific.  Neither python.el nor python-mode.el do anything with tags that I can tell.</p>
<p>Welcome to 80's style code navigation!  <a href="http://en.wikipedia.org/wiki/Ctags">Ctags</a> is a program the analyzes code and creates an index (called a TAGS file).  Unlike a compiler that knows what's going on in your code, the index makes best guesses (using advanced technology such as regexes).  The basic idea is that with this index in hand one can quickly navigate to the definition of a function or class.  (Although it may be ancient tech, there are quite a few editors that support this old school technology, including emacs, jedit, kate, notepad++, vi and even Textmate)</p>
<p>I've been reading through <a href="http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/index.html">Programming in Emacs Lisp</a>, and in section <a href="">4.1</a> it talks about using TAGS files for navigation of elisp files.  So I thought I'd mess around with it in Python.</p>
<p>One way to <a href="http://www.emacswiki.org/emacs/BuildTags">build a TAGS file</a> is to use the <tt>etags</tt> command included in emacs.  I used <a href="http://www.emacswiki.org/emacs/ExuberantCtags">exuberant tags</a>, a more featureful etags replacement (though I'm not really using too many features just the recurse feature (rather than find/pipe/xargs to normal etags)).</p>
<p>Apparently, <a href="http://mg.pov.lt/blog/pylons-with-buildout-2">buildout has support for creating TAG files</a>.  Since I've never used buildout, I can't comment more on that, but it looks straightforward enough for buildout users.</p>
<p>Another way as suggested in <a href="http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/etags.html#etags">section 12.5 "Creating Your Own TAGS File</a> (of the lisp intro book), is to run the command from <tt>M-x compile</tt>.  (Though first you might want to <tt>M-x cd</tt> to get to the root of your project if your current python buffer isn't at the root.  Then instead of running the normal compile command, you'll give something like this (note --recurse is an exuberant feature, also note that "src" should be a directory containing python modules)<pre>etags --recurse=yes src</pre>.  Note, another binary is included with exuberant called <tt>ctags</tt>.  Don't use that one, as emacs will complain about an invalid tag file.</p>
<p>That's all there is to creating TAGS.  Of course, once you edit your files, you need to recreate the TAGS file, as it will be out of date.  (If I find a good way to automate that, I'll post here).</p>
<p>How to use tags?  Well <a href="http://www.emacswiki.org/emacs/EmacsTags">emacswiki has some suggestions for using tags</a>.  The main one is <tt>M-. (find-tag)</tt> which should take you to the definition of said tag (after you point it to the TAGS file you just created).  There's also <tt>tags-search</tt> which is a little like <tt>C-s</tt> but if you follow it with <tt>M-,</tt>, it takes you to all references of a tag which includes going to other files as well.  Quite handy.</p>
<p>If anyone has any more suggestions for tags, I'd love to hear them.  I'd like to look into js/html/css support.  I'll update this post as I use tags more.</p>]]></description><category>emacs</category><category>tags</category><category>ctags</category><category>exuberant tags</category><category>python</category></item><item><title>[ANN] pykeyview</title><guid isPermaLink="true">http://panela.blog-city.com/ann_pykeyview.htm</guid><link>http://panela.blog-city.com/ann_pykeyview.htm</link><pubDate>Mon, 14 Sep 2009 18:28:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=ann%5Fpykeyview</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>In preparation for <a href="http://2009.utosc.com/presentation/119/">my Python Workshop at UTOSC</a>, I thought it might be nice to have a little <a href="http://en.wikipedia.org/wiki/On-screen_display ">OSD</a> widget for showing keystrokes.  (ie if I'm typing an Emacs command, that keystrokes I've typed will show up in big letters)  I've seen something similar in a screencast made on OSX a while back.  So after playing around with glade for a bit and thanks to the existing code in <a href="http://pykeylogger.sourceforge.net/">pykeylogger</a> I've got a little alpha code out that works on my <a href="http://awesome.naquadah.org/">tiling window manager</a> (read floats and moves around and is always on top).  Perhaps when it's prettier and I've implemented some of the stuff on the TODO, I'll post a screencast.</p>
<p>In the meantime if any linux/X users out there are interested in this and want to hack/tweak it feel free.  The code is <a href="http://github.com/mattharrison/pykeyview">up on github</a>.</p>]]></description><category>python</category><category>osd</category><category>pykeyview</category></item><item><title>Countdown to UTOSC 2009</title><guid isPermaLink="true">http://panela.blog-city.com/countdown_to_utosc_2009.htm</guid><link>http://panela.blog-city.com/countdown_to_utosc_2009.htm</link><pubDate>Mon, 14 Sep 2009 18:15:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=countdown%5Fto%5Futosc%5F2009</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p><a href="http://2009.utosc.com/pages/home/">The Utah Open Source Conference</a> is coming up soon.  This a regional community run conference that is now in its 3rd year.  <a href="http://sexysexypenguins.com/">Clint</a> and crew do a bang up job organizing, soliciting participation and generally making sure things run smoothly.  Talks run the gamut from Blender, Cooking, Photography, to FreeBSD and more.  I'll be presenting two times.</p>
<p>I'll be <a href="http://2009.utosc.com/presentation/119/">giving an Intermediate Python Workshop</a> for two hours.  The first half will be lecture and the second half will be a short hands on programming assignment to drill in the material.  If you want to participate in the workshop and would like to learn something not on the current plan, drop me a note.</p>
<p>I'm also giving a <a href="http://2009.utosc.com/presentation/92/">What Every Programmer Should Know About Code Coverage</a> talk later.  This one is more language agnostic, but examples will probably be in Python.</p>
<p>If you are interested in attending the conference, the earlier you sign up the cheaper it is.  Though you should probably find some way of convincing your boss to pay for it.  If you are using Open Source at work, there's bound to be something relevant to your job.</p>]]></description><category>utosc</category><category>python</category><category>code coverage</category></item><item><title>Tornado: Another Python web framework</title><guid isPermaLink="true">http://panela.blog-city.com/tornado_another_python_web_framework.htm</guid><link>http://panela.blog-city.com/tornado_another_python_web_framework.htm</link><pubDate>Thu, 10 Sep 2009 20:03:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=tornado%5Fanother%5Fpython%5Fweb%5Fframework</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>It's cool that Facebook is open sourcing a Python webframework as part of the FriendFeed acquisition.  <a href="http://panela.blog-city.com/python_web_framework_rewrite_take_two.htm">I've blogged about the ease of developing a web framework in Python</a> before.  (Apparently FriendFeed (coming from the Google world) liked Python but not the <a href="http://panela.blog-city.com/python_web_framework_shootout_take_3__petitioning_guido_goog.htm">Googly/Guido/AppEngine Django</a> stuff enough to continue with Django).  <a href="http://www.tornadoweb.org/">Tornado</a> is an part of an effort to open source some Facebook technologies (ala <a href="http://incubator.apache.org/cassandra/">Cassandra</a>?).</p>  
<p>What does Tornado buy you that isn't already available in the many Python frameworks?  The main feature is asynchronous, non-blocking support.  Why not just use <a href="http://twistedmatrix.com/">Twisted</a>?  <a href="http://bret.appspot.com/entry/tornado-web-server">According to co-founder Bret Taylor</a>, they tried Twisted, but <em>"Twisted is very chaotic (see http://twistedmatrix.com/trac/wiki/WebDevelopme... - even they acknowledge this). In general, it seems like Twisted is full of demo-quality stuff, but most of the protocols have tons of bugs."</em>  The Tornado docs claim 4X performance increases over standard (blocking) servers on quad cpu machines (lacking any Twisted benchmarks).</p>
<p>I haven't messed with Tornado, just <a href="http://www.tornadoweb.org/documentation">reviewed the documentation</a>.  Looks pretty straightforward, similar to <a href="http://www.pylonshq.com/">Pylons</a> in that it has no ORM builtin.  There also seems to be much attention placed on security, with easy support for secure cookies and <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">XSRF</a>.  Also the auth mechanism seems to be well thought out with support for Google, Facebook, Yahoo, Twitter.  All of these features are somewhat obvious considering the roots in social networking.<p>
<p>In short it looks like a great start.  Also it's good to know that it has been around that block in that it's been driving FriendFeed. Hopefully this will kick WSGI 2 to have some support for asynchronous servers.  If you are looking for non-blocking support in Python it looks like Tornado should be a top contender.</p>]]></description><category>python</category><category>asynchronous</category><category>friendfeed</category><category>wsgi</category><category>server</category><category>tornado</category></item><item><title>Python and emacs: Articles</title><guid isPermaLink="true">http://panela.blog-city.com/python_and_emacs_articles.htm</guid><link>http://panela.blog-city.com/python_and_emacs_articles.htm</link><pubDate>Sat, 29 Aug 2009 05:13:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=python%5Fand%5Femacs%5Farticles</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>In an attempt to be more proficient at emacs, I've written some articles discussing my adventures.  There seems to be confusing sources of information floating around on the intertubes regarding this subject.  The most authoritative seems to be <a href="http://www.emacswiki.org/emacs/PythonMode">the PythonMode entry on emacswiki</a>.  The <a href="http://wiki.python.org/moin/EmacsEditor">Python wiki entry for emacs</a> seems lacking in much utility.  Then there's the whole python-mode.el (part of the Python distibution), being developed (forked?)<a href="https://launchpad.net/python-mode">on launchpad</a> (and it's accompanying <a href="http://mail.python.org/mailman/listinfo/python-mode">mailing list</a>), and the python.el that ships with emacs.  So, I'll further muddy the waters by providing more information on my blog.</p>
<p>Here's a list of my posts:
<ul><li><a href="http://panela.blog-city.com/python_and_emacs_1_keyboard_macros.htm">Keyboard macros</a></li>
<li><a href="http://panela.blog-city.com/python_and_emacs_2_color_themes.htm">Color Themes (making emacs purty)</a></li>
<li><a href="http://panela.blog-city.com/python_and_emacs_3_balancing_parentheses_and_others.htm">Dealing with parenthesis and "electric" keys and deletes</a></li>
<li><a href="http://panela.blog-city.com/python_and_emacs_4_whitespace_tabs_tabwidth_visualizi.htm">Whitespace - The bane of Python newbies!</a></li>
<li><a href="http://panela.blog-city.com/python_and_emacs_5_pdb_and_emacs.htm">Pdb - Debugging in emacs</a></li>
<li><a href="http://panela.blog-city.com/python_and_emacs_6_exuberant_tags_and_python.htm">Creating/Using TAGS files</a></li>
</ul>
</p>
<p>As I continue to learn and tweak my emacs environment, I'll update this list.  As always, comments, corrections and suggestions are welcome.</p>]]></description><category>emacs</category><category>python</category></item><item><title>[ANN] pycoverage.el</title><guid isPermaLink="true">http://panela.blog-city.com/ann_pycoverageel.htm</guid><link>http://panela.blog-city.com/ann_pycoverageel.htm</link><pubDate>Fri, 28 Aug 2009 06:55:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=ann%5Fpycoverageel</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>I thought it might be nice to have code coverage support for Python in emacs.  So I started hacking pycoverage.el tonight.  The beginnings of the <a href="http://github.com/mattharrison/pycoverage.el/tree">project is on github</a>.  This is just a few hours of hacking, and is in a really nascent state.  Right now there's a hardcoded value for the location of the <tt>.coverage</tt> file (supporting coverage.py initially, I figure figleaf will be easy later).</p>
<p>I've not messed around with git much, but since I figure others might find this useful (and since my lisp skills are lacking (haven't used it since college)) (somehow my parens are pretty good for adding parenthetical information though), I figured I'd throw it out into the social coding scene.  I figure others might want it (and want to help scratch this itch) and since I might be incognito for a bit here anytime now I'm putting it out in a the paint is still wet state....</p>
<p>Props to the <a href="http://eigenclass.org/hiki.rb?rcov">rcov</a> guys for giving me some elisp code to start off with....</p>]]></description><category>coverage</category><category>coveragepy</category><category>figleaf</category><category>python</category><category>emacs</category><category>elisp</category></item><item><title>Python and emacs (5): pdb and emacs</title><guid isPermaLink="true">http://panela.blog-city.com/python_and_emacs_5_pdb_and_emacs.htm</guid><link>http://panela.blog-city.com/python_and_emacs_5_pdb_and_emacs.htm</link><pubDate>Thu, 13 Aug 2009 23:27:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=python%5Fand%5Femacs%5F5%5Fpdb%5Fand%5Femacs</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p><a href="http://docs.python.org/library/pdb.html"><tt>pdb</tt></a> is the interactive debugger the ships with Python (much like gdb).  Though <a href="/a_talk_by_guido_van_rossum.htm">I've heard that many prominent programmers do 90% of their debugging with the <tt>print</tt> statement</a>, sometimes <tt>pdb</tt> is useful for that other 10%.  (Besides that I'm coming to the realization that most production code shouldn't have <tt>print</tt> statements, and if you are using <tt>print</tt> to debug, you should be using <tt>logging</tt> instead, but I digress.)</p>
<center><img src='http://files.blog-city.com/files/F05/96843/p/f/emacspdb.png' title='emacspdb.png'/></center>
<p><tt>pdb</tt> works from the command line like a charm.  So why integrate it with emacs instead of just running it from a terminal?  Or if you live in emacs, from a terminal inside emacs?  For me the main reason is to have another window that shows me where I am in the debugging process.  Sure <tt>pdb</tt> has the <tt>w(here)</tt> command that prints out some lines before and after, but it's so much nicer to have your highlighted code being tracked automagically for you.  See that little triangle in the screenshot above?  So what's the problem with running from within emacs?  Out of the box (gentoo, python 2.5, emacs 22-23) integration with <tt>pdb</tt> doesn't work for me.  There <a href="http://page.sourceforge.net/tricks.html">appears</a> to <a href="http://twistedmatrix.com/projects/core/documentation/howto/debug-with-emacs.html">be</a> a <a href="http://gunnarwrobel.de/wiki/Python.html">few</a> ways of getting <tt>pdb</tt> to work under emacs.  I have my own.</p>
<p>I <a href="http://bugs.python.org/issue1429539">needed to apply this patch</a> and I also need to get around an emacs nicety that turns into an annoyance for me.  See I put all my test files under a <tt>test</tt> directory that sits alongside my main module/package (also the same directory that setup.py is in).  If I have test data I usually reference it using a relative path from that base directory and not the directory that the test code lives in (usually a level down).  But by default whenever emacs enter gud mode it kindly changes to the directory that the file lives in when you invoke <tt>pdb</tt>.  Rather than delving into emacs, I patched my <tt>pdb</tt> again to add <tt>--cwd</tt> support (similar to nose's <tt>-w</tt>).  The result is <a href='http://files.blog-city.com/files/F05/96843/b/pdb'>here (for 2.5)</a>.  For 2.6 I've written a <a href='http://files.blog-city.com/files/F05/96843/b/mypdb.py'>wrapper (<tt>mypdb.py</tt>)</a>(since the aforementioned patch is applied) that gives me my desired <tt>-w/--cwd</tt> support.</p>
<p>To run <tt>pdb</tt> with these scripts, make sure they are executable and in the <tt>PATH</tt>.  Then type <tt>M-x pdb</tt>, when it asks for the command to run type <tt>pdb --cwd /current/directory/you/want/to/use /file/to/debug.py</tt> (make sure pdb points to the 2.5 pdb I provided or change it to mypdb.py for 2.6).  Cheers!</p>]]></description><category>python</category><category>pdb</category><category>emacs</category><category>gud</category><category>gdb</category></item><item><title>rst2odp - &quot;I&apos;m not dead yet&quot;</title><guid isPermaLink="true">http://panela.blog-city.com/rst2odp__im_not_dead_yet.htm</guid><link>http://panela.blog-city.com/rst2odp__im_not_dead_yet.htm</link><pubDate>Wed, 12 Aug 2009 18:07:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=rst2odp%5F%5Fim%5Fnot%5Fdead%5Fyet</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>While I was off at OSCON, it turns out that some people at the PyOhio conference had just found out about rst2odp.  Sadly it didn't work for them.  <a href="http://catherinedevlin.blogspot.com/2009/07/now-thats-agile.html">Happily they had a sprint to fix their issues.</a>  Then they even gave a <a href="http://www.slideshare.net/wamcvey/restructuredtext-to-odp-ooimpress">lightning talk on rst2dop</a>.  And being the good open source citizens they were, they've sent patches back upstream!  I've pushed out a release containing their fixes to <a href="http://pypi.python.org/pypi/rst2odp">PyPI</a>.</p>
<p>So if you are in the business of using <tt>rst2s5</tt> give <tt>rst2odp</tt> a shot.  it includes a sample slide show and instructions for generating it.</p>
<p>(side notes)  I had a lightning talk prepared for PyCon to talk about rst2odp, but figured no one else really cared, and I was scratching my own itch.  I guess I'm a poor marketer.  While at OSCON, I got presenter extraordinaire Damian Conway to review my slides.  He was actually pretty complementary about them (wish I could say the same for other slide decks he reviewed).  I didn't tell him that the slides were programmatically generated....;)<p>]]></description><category>rst2odp</category><category>impress</category><category>ooo</category><category>rest</category><category>rst</category><category>rst2s5</category><category>powerpoint</category></item><item><title>OSCON Scripting with Python Handout</title><guid isPermaLink="true">http://panela.blog-city.com/oscon_scripting_with_python_handout.htm</guid><link>http://panela.blog-city.com/oscon_scripting_with_python_handout.htm</link><pubDate>Thu, 23 Jul 2009 18:57:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=oscon%5Fscripting%5Fwith%5Fpython%5Fhandout</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>As promised, <a href='http://files.blog-city.com/files/F05/96843/b/scripting.tgz'>here's the slides and handout</a> from my recent <a href="http://en.oreilly.com/oscon2009/public/schedule/detail/8317">OSCON talk, Best Practices for Scripting With Python</a>.</p>]]></description><category>python</category><category>scripting</category><category>cheatsheet</category><category>handout</category><category>best practices</category></item><item><title>Buckskin Gulch: Trip notes</title><guid isPermaLink="true">http://panela.blog-city.com/buckskin_gulch_trip_notes.htm</guid><link>http://panela.blog-city.com/buckskin_gulch_trip_notes.htm</link><pubDate>Mon, 13 Jul 2009 14:30:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=buckskin%5Fgulch%5Ftrip%5Fnotes</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>I recently hiked Buckskin Gulch.  <a href="http://en.wikipedia.org/wiki/Buckskin_Gulch">Buckskin Gulch</a> is the longest slot canyon in the world.  At 13 miles long, it can seem repetitive at times.  But when you take someone who hasn't ever been there and you see the look on their face you can appreciate even more.  Some 15 years ago, we tried to hike Buckskin, but were forced to exit at middle trail as we could literally see the water rising as we were standing in a pool.  (It turned out to be ok, since we had time to do a lot of other short hikes like Kaibito Creek (which I think is closed now)).  11 years ago, I was able to hike from the Gulch all the way down to Lee's Ferry, some 42 miles.</p>
<center><img src='http://files.blog-city.com/files/F05/96843/p/f/tallslot.jpg' title='tallslot.jpg'/></center>
<p>This trip was just going to be a quick one.  In at Wire Pass, out at White House.  Two days, 21 Miles.  So we left at 4 in the morning from the SLC area to the Utah/Arizona border between Kanab, UT and Page, AZ.  Got the (mtn bike) shuttle setup and were at Wire Pass at Noon.  Actually started hiking some 40 minutes later.  I wasn't sure how much water there would be at the bottom in the middle of July.  It was about thigh high at the deepest.  Around 8 pm we got to the rock obstacle (it's on the left side, don't go looking for it on the right side, since it can be sketchy/steep over there and you'll probably have wet shoes on), and since it was getting dark we found a nice area with dry dirt just beyond that where we camped.  (Above the real "campsite" with the "seeps" (which looked dry)).</p>
<p>The next morning we were on the trail at 9.  The hike up and out of Paria is dirtier/hotter  and probably wetter than Buckskin.  Buckskin shelters you from the heat and is a nice temperature.  (It's weird there are pockets of heat, but I'd say it was around 70-75 down there, even though it was 96 on top of the canyon).  Paria opens up pretty quickly so one is now exposed.  There is also "quicksand", and the pools/river is slightly deeper.  (Note that I'm talking about July conditions.  And it really doesn't make sense to talk about conditions, since they can vary so much in a slot canyon.  Ie, if it's raining or there's a chance of rain stay out!  In April and June there can be chest high cess pools in Buckskin....)  We were at the White House trailhead by 2pm.  Pretty good time for 21 miles of hiking.  Then I needed to ride the 14 miles of shuttle on my bike.  (4 miles on road, with a decent climb, and 10 miles off).  There was a pretty nasty headwind (or maybe I was just delirious), but that took about 3 hours.  Two cars are recommended!</p>
<p>Some other notes.  We took a 2L of water/day.  We probably could've used 3L/day.  (Paria will clog your filter, and the only water you'd want to drink in Buckskin is at the seeps some 12 (or so) miles down (which we didn't even get to the first day).</p>
<p>Saw a bunch of animals.  Bats, rattlesnakes, (dead) skunk, jackrabbit, lizards, and birds.  Saw a couple small birds that were 'stuck' in the canyon.  They'd fly and get about 4 feet high and hit the side wall (buckskin gulch is probably 100 feet tall or more through most of it) and come tumbling down.  My sister inlaw played the honorary Audubon member and rescued one, but there were others whose fate wasn't so pleasant, as we saw them floating (upside down) in pools.</p>
<p>It was hot at night.  Everyone slept with their sleeping bag open.  Then bugs weren't bad.  But the bats and threat of rattlesnakes/scorpions is in the back of your mind.  I'd bring a sleeping bag 'liner' and use that next time.</p>
<p>A person in the party was deliberating whether to bring their Nikon D80.  So I offered to carry it (having never hiked it with a digital camera, I jumped at the chance).  Probably need some lessons for how to use a fancier camera than the point/shot models I normally use.</p>
<p>Oh and the canyon was awesome.  <a href="http://melionthisandthat.blogspot.com/2009/07/camping-next-to-water.html">Check out my sister's report here.</a>]]></description><category>buckskin</category><category>buckskin gulch</category><category>slot canyon</category><category>paria</category></item><item><title>Helping the Python Excel story</title><guid isPermaLink="true">http://panela.blog-city.com/helping_the_python_excel_story.htm</guid><link>http://panela.blog-city.com/helping_the_python_excel_story.htm</link><pubDate>Fri, 19 Jun 2009 22:15:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=helping%5Fthe%5Fpython%5Fexcel%5Fstory</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>I have <a href="creating_large_excel_spreadsheets_xlwt_in_python.htm">posted</a> <a href="pyexcelerator_xlwt_cheatsheet_create_native_excel_from_pu.htm">previously</a> about Excel and Python.  Which led to my blog being a top hit for those terms for a while.  Chris Withers has decided that there should be <a href="http://www.python-excel.org/">a central hub for reading and writing Excel with Python</a>.  This is great and should help provide a clearer story for Python and Excel (remember folks, these libraries are pure python, so you can generate .xls on your Mac or Linux (or MS) box).</p>
<p><a href="http://blog.insightvr.com/?p=110">As my brother noted</a> if you are looking for professional assistance in generating .xls in python (or for that matter Python in general) feel free to contact me.</p>]]></description><category>python</category><category>excel</category><category>xls</category><category>no com</category><category>xlwt</category><category>xlrd</category></item><item><title>Early father&apos;s day....</title><guid isPermaLink="true">http://panela.blog-city.com/early_fathers_day_1.htm</guid><link>http://panela.blog-city.com/early_fathers_day_1.htm</link><pubDate>Wed, 03 Jun 2009 04:22:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=early%5Ffathers%5Fday%5F1</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>My kind wife let me and a buddy get away last week.  We wanted to hike <a href="http://climb-utah.com/CM/blackhole1.htm">the Black Hole</a> but the 30% chance of rain scared us out of walking down a slot canyon that drains large swaths of land.  So, instead we left for Moab early in the morning.  Rode on the surreal terrain of <a href="http://www.utah.com/bike/trails/slickrock.htm">Slickrock</a>.  Rode into <a href="http://stateparks.utah.gov/stateparks/parks/dead-horse/">Dead Horse Point</a>, and saw a fascinating interaction between a ladybug, lizard and hummingbird.  Saw <a href="http://www.blm.gov/ut/st/en/fo/moab/recreation/rock_art.html">"Indian Writing"</a>.   Climbed a crazy (too much run out) <a href="http://www.rockclimbing.com/photos/Sport/Superflea_on_Slab_5.8_59655.html">slab</a> at <a href="http://www.rockclimbing.com/routes/North_America/United_States/Utah/Moab/Wall_Street/">Wallstreet</a>.  Played Disc Golf at <a href="http://moabdiscgolf.mindfloss.com/">a brand new 18 hole course</a>.  That was the first day.  Exhausting and awesome.</p>
<img src='http://files.blog-city.com/files/F05/96843/p/f/slickrock.jpg' title='slickrock.jpg'/>
<p>The next day we went to an Ultimate Hat Tournament.  We played some nice <a href="http://panela.blog-city.com/howto_make_hoops_for_goaltimate_goaltimate_kit.htm">Goaltimate</a> (although the hoop was slightly oversized).  Then we split up into teams, and played some 5 games.  Twas fun.  The parks/fields in Moab are super plush and green.  (Much nicer than in Salt Lake.)  I forgot how much stuff there is to do around Moab....</p>
<p>Now I need to find a way to pay back the wife....</p>]]></description><category>moab</category><category>ultimate</category><category>rock_climbing</category><category>dead_horse_point</category><category>slickrock</category><category>mountain_biking</category><category>disc_golf</category><category>goaltimate</category></item><item><title>Another reason to learn python: outsourcing insurance</title><guid isPermaLink="true">http://panela.blog-city.com/another_reason_to_learn_python_outsourcing_insurance.htm</guid><link>http://panela.blog-city.com/another_reason_to_learn_python_outsourcing_insurance.htm</link><pubDate>Wed, 29 Apr 2009 17:44:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=another%5Freason%5Fto%5Flearn%5Fpython%5Foutsourcing%5Finsurance</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p><a href="http://sayamindu.randomink.org/ramblings/2009/04/29/why-should-i-bother/">Looks like they won't be outsourcing your python job to India soon ;)</a>  (via <a href="http://planet.sugarlabs.org/atom.xml">Planet Sugar</a>)  <a href="http://panela.blog-city.com/another_picture_from_india.htm">When I was in India</a> it was clear people were reluctant to work for a small company, there was much pride in being a Java-drone at a large company.  Perhaps this is similar to languages.  Where is the pride in knowing python if half the people you talk to (who are technical) don't even know what it is?</p>]]></description><category>python</category><category>india</category><category>javadrone</category></item><item><title>Python and emacs (4): Whitespace, tabs, tab-width, visualizing...</title><guid isPermaLink="true">http://panela.blog-city.com/python_and_emacs_4_whitespace_tabs_tabwidth_visualizi.htm</guid><link>http://panela.blog-city.com/python_and_emacs_4_whitespace_tabs_tabwidth_visualizi.htm</link><pubDate>Thu, 09 Apr 2009 18:41:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=python%5Fand%5Femacs%5F4%5Fwhitespace%5Ftabs%5Ftabwidth%5Fvisualizi</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>Whitespace!  The bane of all aspiring python programmers!  After their first day of python programming, it never seems to bother them.  Until they get the dreaded file that uses tabs instead of more useful spaced indentations.  (I've heard 6 is the new 2.  At least that's what they're teaching at MSU).</p>
<p>Emacs (builtin python-mode) allows you to just open their tab delimited files and start working with them just fine.  You will follow pep8, and be consistent.  No harm done.  Allow the infidels to keep their tabs.</p>
<p>Now weird spaced indentation (ala googly 2 space or MSU 6 space), is handled pretty easily as well.  Just use <tt>M-x set-variable tab-width</tt> to the appropriate size.  (<tt>M-x describe-variable tab-width</tt> will show the current value).  (A better explanation of tabs/spaces in emacs is <a href="http://student.northpark.edu/pemente/emacs_tabs.htm">found here</a>)</p>
<p>The real problems come when tabs/spaces are intermixed.  Out of the box emacs handles that pretty well too.  Select a region (<tt>C-x h</tt> (to select the whole buffer)) and <tt>M-x untabify</tt> will replace tabs with the <tt>tab-width</tt> number of spaces.  That works pretty well too.  (There's also the <tt>tabify</tt> command for you infidels).</p>
<p>Since some of the fancy gui editors/IDEs out there visually highlight the differing indentation, surely you should be able to replicate this on your emacsen.  Alas, <a href="http://www.emacswiki.org/">emacswiki</a> to the rescue.  After an initial hint to look at "blank-mode", it turns out that <a href='http://www.emacswiki.org/emacs/WhiteSpace'>whitespace-mode</a> is the blank-mode++, (blank-mode was so 2006).  Plus documentation found in the wiki is quite nice.</p>
<p>If you have mixed indentation in python, whitespace-mode is handy.  I'm finding it even more handy in my html templates that have dynamic css/js/html (where I've yet been able to get an editor to understand what it's supposed to be doing.  Yeah, some of it could be isolated to it's own files.  Some of it is dynamic and the templating languages further confuse emacs).  So when your co-workers might be using Textmate (which might also be confused on such files), tabs might find their way in.  <tt>whitespace-mode</tt> allows one to quickly view and clean up their until now hidden snafus.</p>
<p>The screenshot below illustrates <tt>whitespace-mode</tt>.  In the top buffer is a previously mentioned html template.  Red indicates extra space at the end of the line.  <tt>&gt;&gt;</tt> indicates evil tabs.  Dots indicate spaces, and <tt>$</tt> is newline.  You can see that one line has spaces and tabs intermixed!  Arghh, my eyes are burning!  The middle buffer shows some python code using tabs with whitespace-mode off.  The bottom buffer shows the same code with whitespace-mode on.</p>
<img width=545 src='http://files.blog-city.com/files/F05/96843/p/f/whitespacemode.png' title='whitespacemode.png'/>
<p>I'm not going to leave <tt>whitespace-mode</tt> on all the time.  On clean code it's distracting.  But when I'm feeling like refactoring/cleanup/examining new code it comes in handy.</p>]]></description><category>python</category><category>emacs</category><category>whitespace</category><category>whitespacemode</category><category>die_tabs</category><category>spaces</category></item><item><title>Clone Digger - another tool to add to your python belt</title><guid isPermaLink="true">http://panela.blog-city.com/clone_digger__another_tool_to_add_to_your_python_belt.htm</guid><link>http://panela.blog-city.com/clone_digger__another_tool_to_add_to_your_python_belt.htm</link><pubDate>Fri, 20 Mar 2009 04:11:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=clone%5Fdigger%5F%5Fanother%5Ftool%5Fto%5Fadd%5Fto%5Fyour%5Fpython%5Fbelt</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>A few years back my boss asked me how I would implement code duplication detection.  Real duplication would ignore variable renames, comments, and indenting (for non-python).  A naive solution would just use string comparisons and not be too useful.  I thought about it for a minute and said I'd make an <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST</a> and for the code and compare the trees.  Not that it's a particularly novel idea, we were just discussing the value of the IP of some companies...</p>
<p>Well, there's been code floating around the intertubes for the past year or so that does just this for python code.  The project is called <a href="http://clonedigger.sf.net/">Clone Digger</a> and works on Python and Java.  The <a href="http://clonedigger.sourceforge.net/examples.html">output is an html file</a> showing chunks of code that either differ by variables or operation changes (in red) or code that is the same (in blue).</p>
<p>I think Clone Digger is another useful tool to use for code reviews, when inheriting a bit of code, or after developing a chunk of code.  This is going to be very useful for some refactoring we are doing at work.  Now if it only worked on JavaScript....</p>]]></description><category>python</category><category>clonedigger</category><category>duplication</category><category>java</category></item><item><title>Utah Python March 2009: GridBackup</title><guid isPermaLink="true">http://panela.blog-city.com/utah_python_march_2009_gridbackup.htm</guid><link>http://panela.blog-city.com/utah_python_march_2009_gridbackup.htm</link><pubDate>Tue, 17 Mar 2009 04:45:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=utah%5Fpython%5Fmarch%5F2009%5Fgridbackup</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>Had <a href="http://utahpython.googlegroups.com/web/UtahPUG_Presentation_3-12-09.pdf?gda=PW2nQlIAAAB1l_6DcYtVQYl1BuwdXTUkVlG2RcRCYkbtxgGA590XHIzOZqT_9Zt-LELOT1ROxsUvJVZJirdoDlMvIPHMMW_vVeLt2muIgCMmECKmxvZ2j4IeqPHHCwbz-gobneSjMyE">a great presentation by Shawn Wilden</a> on GridBackup.  GridBackup is a friendnet that he's building on top of <a href="http://www.allmydata.org/">the allmydata tahoe grid</a>.  It's a work in progress, but he's clearly done some up front thinking as evident from his slides.</p>
<p>Shawn's aim is to have the (dumb) end user install an application on their windows/mac/linux box and have it just work as a complete backup system.  Sounds like a great goal.  It will be fun to follow.  Wouldn't it be sublime if a <a href="http://www.dd-wrt.com/">dd-wrt-like</a> firmware included a friendnet solution such as this out of the box?</p>]]></description><category>allmydata</category><category>gridbackup</category></item><item><title>Easy slideshow creation with rst2odp</title><guid isPermaLink="true">http://panela.blog-city.com/easy_slideshow_creation_with_rst2odp.htm</guid><link>http://panela.blog-city.com/easy_slideshow_creation_with_rst2odp.htm</link><pubDate>Tue, 17 Mar 2009 04:27:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=easy%5Fslideshow%5Fcreation%5Fwith%5Frst2odp</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>I've used <a href="http://pypi.python.org/pypi/rst2odp/">rst2odp</a> a few times now for slide generation.  It does a pretty good job.  It's still lacking some <a href="http://docutils.sourceforge.net/docs/user/slide-shows.html">features that the s5 stuff has</a>, but has other features.  Notably missing is footers (the support is in there in the backend library I just don't care for them so I've yet to hook them up in the rst2odp script), table support (again haven't needed to scratch that itch, but would be easy to add), incremental mode only supported in lists (not paragraphs, this is a feature of OOo/ppt), image placement is basic, and only supporting one text frame.  Also there is support for slide import (from existing decks, even works for ppt (if you convert it to odp)) in the backend, just haven't written the rst directive for it.</p>
<p>Here's some features that are different from rst2s5.</p>
<p><b>Titleless slides</b>  Instead of underlining some words for a title, just underline nothing and you'll get a blank title.  I use this in combination with:</p>
<p><b>Centered huge text</b>  like so:
<pre>

--------

.. class:: center huge

A slide with centered, huge text and no title

</pre>
<p><b>Source code formatting</b>  Thanks to <a href="http://www.pygments.org/">pygments</a> we get source formatting like so:</p>
<pre>

Source code
-----------

.. code-block:: python

  def foo(bar, baz):
    fizzle(bar, baz)

</pre>
<p>Pretty straightforward eh?  The tarball includes a <tt>doc</tt> directory with an example slideshow illustrating the features.  To generate a slideshow using an OOo template do the following:</p>
<pre>
rst2odp slides.rst --template-file template/darkGradient.otp output.odp
</pre>
<p>Then use OOo to present it.  Or convert to PPT or PDF and use your favorite viewer....</p>]]></description><category>rst2odp</category><category>rst2s5</category><category>odp</category><category>ooimpress</category><category>ooo</category><category>powerpoint</category><category>slides</category></item><item><title>Python and emacs (3): (Balancing) parentheses and others</title><guid isPermaLink="true">http://panela.blog-city.com/python_and_emacs_3_balancing_parentheses_and_others.htm</guid><link>http://panela.blog-city.com/python_and_emacs_3_balancing_parentheses_and_others.htm</link><pubDate>Tue, 10 Mar 2009 19:54:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=python%5Fand%5Femacs%5F3%5Fbalancing%5Fparentheses%5Fand%5Fothers</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>(Again not necessarily python specific)</p>
<p>One nice feature of emacs is <a href="http://www.emacswiki.org/emacs/ShowParenMode">show-paren-mode</a>.  (Naming it show-paren-mode rather than paren-show-mode makes it somewhat less discoverable but I digress).  This nice little feature allows one to make sure parens (or brackets or curly brackets) are in order.  It does so by visually highlighting the matching pair when the cursor is over the starting one (or after the ending one).  It's very useful when you have a long dictionary with lists as values.  The <a href="http://www.emacswiki.org/emacs/ShowParenMode">emacs wiki page</a> includes a function for showing matching ends when one is offscreen.  Very handy indeed.</p>
<p>To enable show-paren-mode type <tt>M-x show-paren-mode</tt> or put something like this in your .emacs:
<pre>
;; highlight balanced parens
(add-hook 'python-mode-hook (lambda () (show-paren-mode 1)))
</pre>
</p>
<p>Apparently one of the critically acclaimed of Textmate is autopairs (or something like that).  People love it cause it saves them a keystroke.  If you type an opening paren, it adds a closing paren and moves the cursor inside the parens.  Nice!  How to get that in emacs?</p>
<p>As always in the open source world, there are many ways.  Here's what I went through:</p>
<p>I searched for electric pair and found <a href="http://www.emacswiki.org/emacs/ElectricPair">this entry in the emacs wiki</a>.  It's a good start but it has some drawbacks.  It only inserts the matching pair when the cursor is at the end of the line (admittedly that's probably the case 80% of the time).  So it won't work on nested items (say a string inside a list).</p>
<p>To deal with that first issue I tried <a href="http://www.emacswiki.org/emacs/SkeletonMode#toc12">skeleton mode</a>.  This gets around the embedding issue.</p>
<p>Then I find this <a href="http://cmarcelo.wordpress.com/2008/04/26/a-little-emacs-experiment/">blog post</a> illuminating me on the second issue.  I didn't think of this at first but if you have electric completes you probably want electric deletes too.  So I'm currently using a modified version of <a href="http://littlechina.org/~cmarcelo/paren-experiment.el">his code</a> (added support for single quote).  This appears to handle triple quoting that is common in python docstrings too.</p>
<p>Marcelo's blog also mentioned <a href="http://www.emacswiki.org/cgi-bin/wiki/ParEdit">paredit</a> which seems to be quite featureful for lisp source, but has issues with python (no single quotes, space inserted between started paren and previous character, complex source).  So I only tried it for a minute or so.</p>
<p>Good luck with your balancing!</p>]]></description><category>emacs</category><category>python</category><category>showparenmode</category><category>emacswiki</category><category>skeletonmode</category><category>electricpair</category><category>paredit</category></item><item><title>Python and emacs (2): Color themes</title><guid isPermaLink="true">http://panela.blog-city.com/python_and_emacs_2_color_themes.htm</guid><link>http://panela.blog-city.com/python_and_emacs_2_color_themes.htm</link><pubDate>Mon, 09 Mar 2009 17:18:00 GMT</pubDate><comments>http://panela.blog-city.com/console/comments/popup/?f=python%5Fand%5Femacs%5F2%5Fcolor%5Fthemes</comments><dc:creator>Matt</dc:creator><description><![CDATA[<p>(Not really python specific)</p>
<p><a href='http://www.reddit.com/r/emacs/'>Emacs.reddit</a> recently had <a href='http://jblevins.org/projects/emacs-color-themes/'>two</a> <a href='http://www.cs.cmu.edu/~maverick/GNUEmacsColorThemeTest/index-el.html'>posts</a> dealing with emacs color themes.  Coincidentally, I had just installed <a href='http://www.emacswiki.org/emacs/ColorTheme'>color-theme</a> last Friday and was playing around with it.  I was getting sick of black on white.  Sadly, I really didn't like a lot of the pre-installed themes with color-theme.  Some of them change your fonts (which color-theme says not to do, though it is cool to see comments in non-mono spaced fonts), others just appear to try and provide the most shock values (or contrast).  Another thing I wanted was bold keywords (just so they would visually be distinct from non keywords).  So combining my two requirements, easy to look at, and bold keywords left me in somewhat of a pickle.  Until I found this <a href='http://www.emacswiki.org/cgi-bin/emacs/color-theme-tango.el'>nice theme based on tango</a>.  <a href='http://tango.freedesktop.org/Tango_Desktop_Project'>(Tango is a set of icons and color guidelines for freedesktops.)</a></p>
<img src='http://files.blog-city.com/files/F05/96843/p/f/emacstango.png' title='emacstango.png'/>
<p>I just added the definition for the tango theme directly to my .emacs. (I should probably start to break this stuff up like the <a href='http://github.com/technomancy/emacs-starter-kit/tree'>emacs starter kit</a> (which sadly ignores the existence of python, ruby snobs...)).  I guess it's good that my theme is somewhere where I manage, rather than crammed in with the others in the the color-theme file.  Then I can tweak it if I feel so.  All is well and good, until I start emacs in a terminal, which only support 256 colors...  So I default to a TTY friendly theme while running in a console.</p>
<pre>
;; color theme (requires http://www.emacswiki.org/cgi-bin/wiki?ColorTheme )
(require 'color-theme)
(color-theme-initialize)

;;
(if window-system
    (color-theme-tango))
(if (not (window-system))
    (color-theme-tty-dark))

</pre>
<p><b>update</b> - Tools like <tt>ecb</tt> can make your nicely tweaked color theme, look like lipstick on a pig.  Use <tt>M-x list-faces-display</tt> to find the offending faces.  Update them in your config as needed.</p>
<p><b>update</b> - Here's the font/color theme I'm currently using.  I'm still tweaking, but it's a start...
<pre>;; the following is size 7 for me...
(set-face-font 'default "-unknown-Envy Code R-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1")
;;(set-default-font "Envy Code R-7") ;; doesn't work consistently ;(

;;; Color theme based on Tango Palette. Created by danranx@gmail.com
;;; http://www.emacswiki.org/cgi-bin/emacs/color-theme-tango.el
(defun color-theme-tango ()
  "A color theme based on Tango Palette."
  (interactive)
  (color-theme-install
   '(color-theme-tango
     ((background-color . "#2e3436")
      (background-mode . dark)
      (border-color . "#888a85")
      (cursor-color . "#fce94f")
      (foreground-color . "#eeeeec")
      (mouse-color . "#8ae234"))
     ((help-highlight-face . underline)
      (ibuffer-dired-buffer-face . font-lock-function-name-face)
      (ibuffer-help-buffer-face . font-lock-comment-face)
      (ibuffer-hidden-buffer-face . font-lock-warning-face)
      (ibuffer-occur-match-face . font-lock-warning-face)
      (ibuffer-read-only-buffer-face . font-lock-type-face)
      (ibuffer-special-buffer-face . font-lock-keyword-face)
      (ibuffer-title-face . font-lock-type-face))
     (border ((t (:background "#888a85"))))
     (fringe ((t (:background "grey10"))))
     (mode-line ((t (:foreground "#eeeeec" :background "#555753"))))
     (region ((t (:background "#555753"))))
     (font-lock-builtin-face ((t (:foreground "#729fcf"))))
     (font-lock-comment-face ((t (:foreground "#888a85"))))
     (font-lock-constant-face ((t (:foreground "#8ae234"))))
     (font-lock-doc-face ((t (:foreground "#888a85"))))
     (font-lock-keyword-face ((t (:foreground "#729fcf" :bold t))))
     ;; remove italic from strings
     (font-lock-string-face ((t (:foreground "#ad7fa8"))))
     (font-lock-type-face ((t (:foreground "#8ae234" :bold t))))
     (font-lock-variable-name-face ((t (:foreground "#eeeeec"))))
     (font-lock-warning-face ((t (:bold t :foreground "#f57900"))))
     (font-lock-function-name-face ((t (:foreground "#edd400" :bold t :italic t))))
     ;; ECB - matt added
     ;; see - http://ecb.sourceforge.net/docs/ecb-faces.html
     (ecb-default-highlight-face((t (:background "#75507b"))))
     ;; end ecb
     (comint-highlight-input ((t (:italic t :bold t))))
     (comint-highlight-prompt ((t (:foreground "#8ae234"))))
     (isearch ((t (:background "#f57900" :foreground "#2e3436"))))
     (isearch-lazy-highlight-face ((t (:foreground "#2e3436" :background "#e9b96e"))))
     (show-paren-match-face ((t (:foreground "#2e3436" :background "#73d216"))))
     (show-paren-mismatch-face ((t (:background "#ad7fa8" :foreground "#2e3436"))))
     (minibuffer-prompt ((t (:foreground "#729fcf" :bold t))))
     (info-xref ((t (:foreground "#729fcf"))))
     (info-xref-visited ((t (:foreground "#ad7fa8"))))
     
     )))

;; color theme (requires http://www.emacswiki.org/cgi-bin/wiki?ColorTheme )
(require 'color-theme)

;;
(if window-system
    (color-theme-tango))
(if (not (window-system))
    (color-theme-tty-dark))
</pre>
</p>]]></description><category>emacs</category><category>colortheme</category><category>tango</category></item></channel></rss>