Articles tagged python

  1. @x.setter syntax in Python 2.5

    By Floris Bruynooghe

    The new property.setter syntax in Python 2.6 and 3.0 looks very clean to me. So I couldn't wait and wanted it in Python 2.5. With the help of comp.lang.python I finally got there (thanks especially to Arnaud Delobelle):

    _property = property
    class property(property):
        def …
  2. nose and ipython

    By Floris Bruynooghe

    I wish there was a simple way to integrate nose and ipython. Something like a command line option not to catch exceptions would be sufficient I think, so that you could do:

    In [1]: %run tests/ --do-not-catch-exceptions

    Obviously you'd want a shorter option switch...

    Seems like …

  3. GPL and python modules

    By Floris Bruynooghe

    I should probably google this, but can't think of good keywords. So instead this is a "dear lazy web" post.

    Is importing a python module considered linking for the GPL? I.e. are you allowed to import a python module into an script or module that has a non-GPL-comptible license …

  4. Docstring folding

    By Floris Bruynooghe

    In my last post I had a little rant about how python docstrings visually separate the function/method/class definition from the body. Mikko Ohtamaa raised a very good point though: the editor should fold it away.

    Since my editor of choice is Emacs, said to be more an operating …

  5. Documenting functions/methods/classes

    By Floris Bruynooghe

    There are several simple guidelines for writing functions or methods (guidelines that I like that is).

    • Keep them clean, don't intersperse them with comments. If they require more then one or two inline comments it's too complicated and you should restructure.
    • Keep them short, it should fit on one screen …
  6. Seeing your browser's headers using python

    By Floris Bruynooghe

    There's a very annoying website that won't send their CSS to my normal web browser (epiphany ) which makes it rather ugly. However when I use iceweasel the CSS gets applied. Since both browsers use exactly the same rendering engine, gecko, on my machine as far as I know, I thought …

  7. There's a first time for everying

    By Floris Bruynooghe
    flub@signy:~/src$ tar -xzf storm-0.10.tar.gz
    gzip: stdin: not in gzip format
    tar: Child returned status 1
    tar: Error exit delayed from previous errors
    flub@signy:~/src$ file storm-0.10.tar.gz
    storm-0.10.tar.gz: POSIX tar archive (GNU)
    flub@signy:~/src$ mv storm-0.10.tar …
  8. Source code to my music player

    By Floris Bruynooghe

    Recently I said I created an increadably stupid, dump and boring GTK music player. I also offered to make the source code available in the very unlikely case someone else would find this thing interesting. I should have known to just do that right away, so here it is.

  9. My very own music player

    By Floris Bruynooghe

    Yes, I've contributed to the masses of music players out there. It is pleasantly easy using python and the pygtk and pygst modules.

    But why yet an other music player? Well it is, intentionally, increadably simple.

    • No library. Just a simple list of files, played sequentially.
    • No metadata. If you …
  10. Gazpacho and libglade

    By Floris Bruynooghe

    If you read my last post about using Gazpacho you should read the comment by Johan Dahlin too. He's one of the authors of Gazpacho and explains the libglade and save format issues^Wthings in Gazpacho nicely.

  11. Making GUI applications with Gazpacho

    By Floris Bruynooghe

    Earlier I have made some simple GUI applications using PyGTK and Glade, which is surprisingly easy. Now I have another small itch to scratch and have another go at some GUI app. Only this time I decided that the coolness of Gazpacho looked slightly nicer to me, so gave that …

  12. Optimising python code by AST fiddling

    By Floris Bruynooghe

    Obviously no real optimisation, just optimisation exactly like python -O [-O] would create. But in "normal" byte compiled files, i.e. in .pyc files instead of .pyo files.

    Why would I want to do that? Well, we really don't feel like shipping code with assert statements or if __debug__: ... bits …

  13. How to choose a web framework?

    By Floris Bruynooghe

    So I have a bit of organically growing information that is nice to represent on internal web pages in a semi-organised fashion. The first iteration just runs a few python scripts from some cron jobs that utilise SimpleTAL to create staticly served pages. SimpleTAL as templating language simply because we …

  14. __slots__: worth the trouble?

    By Floris Bruynooghe

    I find __slots__ annoying. They seem to have a lot of rules about their use and make things like a borgs rather awkward to use (I even prefer to use a singleton instead of a borg in new-style classes because of this).

    And all it does is safe some space …

  15. IPC in the stdlib(?)

    By Floris Bruynooghe

    Many interesting comments on my last musings about IPC. Each and every one of them look very nice and have their application area, go and have a look! These found a weak spot in my heart though:

    • Candygram is Erlang style message passing. Very stunning, but to my liking a …
  16. IPC and the GIL

    By Floris Bruynooghe

    As recently described excelently, threads are ugly beasts, waiting to get you when you let your guard down (and eventually you will). Yes, that means that I should really get my head round the asynchat module and stop using ThreadingMixIn with the SocketServer, but that's not the point of this …

  17. More roundup love

    By Floris Bruynooghe

    As I've said before, roundup is an amazing issue tracker. Last time I wrote I had just implemented our internal bug tracker with all the weird requirements of a few developers. By now the incredibly flexible system, thanks to python, has been moulded into our complete project management tracker.

    This …

  18. Timers for profilers

    By Floris Bruynooghe

    After some oh... and ah... experiences I have decided that the only timer that will give you correct results in a portable manner (accross POSIX platforms that is) is resource.getrusage(resource.RUSAGE_SELF) and os.times(). This is rather shocking, certainly after I then went on to discover that on …

  19. Schizophrenic thoughts

    By Floris Bruynooghe

    On one hand I use tab-completion on the command line all the time. I even go as far as creating my own -terribly incomplete- completion functions in bash for commands that I use often

    On the other hand, when programming I don't use tab-completion -maybe mostly because it's not so …

  20. Roundup praise

    By Floris Bruynooghe

    Roundup is just an amazing bug tracking system. It really is way more general then that, their own words for it are not bad: an issue tracking system for knowledge workers.

    Why I love it:

    • It's written in python
    • It has a poweful and flexible concept/abstraction of a database …
  21. Writing applications as modules

    By Floris Bruynooghe

    The Problem

    I recently had to write a few command line applications of the form command [options] args that did some stuff, maybe printed a few things on screen and exited with a certain exit code. Nothing weird here.

    These apps where part of a larger server system however and …

  22. Warnings revisited (aka logging vs warnings)

    By Floris Bruynooghe

    Earlier I posted about how to make warning messages from warnings.warn() look like fairly normal messages so they don't give you all the details about which line of code called them. The result was neat, but I found it a fairly crude way of doing it.

    There is another …

  23. Overriding formatting of warnings.warn()

    By Floris Bruynooghe

    Today I needed to add the printing of warning messages to a command line tool written in Python. So Instead of writing things out using print, wich is not flexible enough and goes against my way to avoid user interaction deep inside functions and classes, I decided to use the …

  24. site, eggs, etc.

    By Floris Bruynooghe

    Before I complained about why .pth files are not processed in files on in your $PYTHONPATH. I got a few pointers in that regard, thanks for them. And now I know why it doesn't happen: you can import foo, bar;; bar.harm() inside a .pth file. Since this …

  25. site module musings

    By Floris Bruynooghe

    The site package reads .pth files and inserts directories listed there in sys.path. However it only scans lib directories ( lib/python2.4/site-packages/ and lib/python/site-python/ on UNIX) starting with sys.prefix or sys.exec_prefix for these .pth files. Thus if you install a module distribution using the …

  26. Python web frameworks

    By Floris Bruynooghe

    It appears discussing web frameworks is popular currently. It also appears GvR has decided he likes Django and hopes it will become sort of the default.

    I've been looking at this Django and TurboGears things for a while unable to decide if I should move the website that I appear …

  27. setup(..., extra_path="foobar", ...)

    By Floris Bruynooghe

    The extra_path keyword that you can pass to setup() when using the distutils for building and installing a package is completely undocumented as far as I know. I have no idea how I found it the first time (about a year ago) but now it was there and was not …

  28. Today's WTF: sys.path in python != sys.path in ipython

    By Floris Bruynooghe

    Spot the current directory ( <snip>/build/lib.linux-i686-2.4) in the path:

    <snip>/build/lib.linux-i686-2.4$ echo $PYTHONPATH
    <snip>/build/lib.linux-i686-2.4$ python
    Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
    [GCC 4.0.3 (Ubuntu …
  29. Summer of Code 2006

    By Floris Bruynooghe

    There must be about a million blog posts with this title by now. Anyway, here my own little addition, I've been meaning to write this for a while.

    I have not applied for SoC again althoug I was still eligible. There where intresting projects however, and in fact I'm sorry …

« Page 3 / 4 »