1. A Modest Proposal for Tech Conferences

    After more difficulty than expected, I'm at PyOhio, and once again I found myself not taking notes during today's sessions, but madly scrambling to open browser tabs to each of the open source projects, blog posts, and other online resources the presenters mentioned. It's a rush to keep up, particularly with laundry-list-of-links slides!

    The sessions at PyOhio (and most other conferences I attend) are recorded and posted online, but I never seem to make the time to look for the links after the fact -- and you can't click a link in a video of a projected slide anyway.

    So this has gotten me thinking: since presenters typically submit talks through web forms, why not also ask them for a listing of the resources that are a part of their presentation, and preserve this in the online talk notes? A few words on the subject of the link would be nice as well, but with not that much cleverness, this could be extracted from the page. Knowing that this will be available after the fact frees presenters to move fluidly through their presentations, and allows attendees to focus on the content rather than trying to type URLs as quickly as possible.

    Perhaps not everyone will be willing to take the time to fill out what, to them, surely seems like a busy-work form, but with the right application of social pressure, and after the expectation has been set that speakers will do this, I suspect that a majority would be willing to make the effort.


  2. What the heck is an xrange?

    Pop quiz: how would you implement Python's xrange (known in Python 3.x as range) in Python and without making a list or any other sequence type?

    If you answered "with a generator," you'd be wrong! And it's likely because you've only ever used an xrange in code like:

    for i in xrange(10):
        # do something 10 times
    

    In this case (where the xrange is only used as an "argument" to a for loop), a generator would probably suffice. But, in fact, xrange is implemented as an object, not a function or generator. Why? Let's find out.


  3. The exec Statement and A Python Mystery

    A few weeks ago I examined Python code objects using the dis module. In that post, I showed several examples of executing code objects created at runtime using the exec statement; here we'll explore compile()'s compliment, exec, how to invoke it, and some of the quirks of using it.


  4. A Python "Cast Constructor"

    Very occasionally, I write code where I'm given an object of some class (usually from a library call), but I wish to use additional methods on that class as though they had been defined there. In some languages (Objective-C shines in this regard with categories), you can do this very naturally. In Python, most people probably resort to monkey patching to accomplish this.


  5. Exploring Python Code Objects

    Inspired by David Beazley's Keynote at PyCon, I've been digging around in code objects in Python lately. I don't have a particular axe to grind, nor some particular task to solve (yet?), so consider this post just some notes and ramblings that might be of interest (and my apologies if not).

    Disclaimer: This post is about CPython version 2.7, though much of it is also likely true for other CPython versions (including 3.x). I make no claims to its accuracy or applicability to PyPy, Jython, IronPython, etc.


Page 4 / 7