Now I'm debating if I should really use that in production code...
Articles tagged python
-
-
@x.setter syntax in Python 2.5
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 …
-
nose and ipython
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/test_module.py --do-not-catch-exceptions
Obviously you'd want a shorter option switch...
Seems like Test.run …
-
GPL and python modules
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 …
-
Docstring folding
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 …
-
Documenting functions/methods/classes
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 …
-
Seeing your browser's headers using python
-
There's a first time for everying
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 …
-
Source code to my music player
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.
-
My very own music player
-
Gazpacho and libglade
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.
-
Making GUI applications with Gazpacho
-
Optimising python code by AST fiddling
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 …
-
How to choose a web framework?
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 …
-
__slots__: worth the trouble?
-
IPC in the stdlib(?)
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 …
-
IPC and the GIL
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 …
-
More roundup love
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 …
-
Timers for profilers
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 …
-
Schizophrenic thoughts
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 …
-
Roundup praise
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 …
-
Writing applications as modules
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 …
-
Warnings revisited (aka logging vs warnings)
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 …
-
Overriding formatting of warnings.warn()
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 …
-
site, eggs, etc.
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; foo.do(); bar.harm() inside a .pth file. Since this …
-
site module musings
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 …
-
Python web frameworks
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 …
-
setup.py: setup(..., extra_path="foobar", ...)
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 …
-
Today's WTF: sys.path in python != sys.path in ipython
Spot the current directory ( <snip>/build/lib.linux-i686-2.4) in the path:
<snip>/build/lib.linux-i686-2.4$ echo $PYTHONPATH /home/flub/lib/python:/home/flub/lib/python2.4: <snip>/build/lib.linux-i686-2.4$ python Python 2.4.3 (#2, Apr 27 2006, 14:43:58) [GCC 4.0.3 (Ubuntu …
-
Summer of Code 2006
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 …