All Articles

  1. Porting a C extension module to py3k

    This was not that hard! First look at what everyone else has to say about this, nice aggregated on the python wiki. It covers a lot.

    Now for what I discovered on top of this:

    • When you're defining a new type self->ob_type doesn't exist anymore. This is a problem …

  2. Generating source files in setup.py

    I have a Python extension module written in C and one of the weirder things it needs to do is have a number of module constants with their values which are defined (e.g. #define PREFIX_FOO 0x01 etc.) in an external C header file. All the defined names in that …

  3. Finding memory leaks in Python extension modules

    Valgrind is amazing, even if you've never used it before it's basic usage is really simple:

    $ valgrind --tool=memcheck --leak-check=full /usr/bin/python ./test.py
    

    This is enough to point you at the places in your extension module where you allocated stuff that didn't get freed later. This is …

  4. gcc, LD_RUN_PATH & Solaris

    I actually started writing a long post about how linking against shared libraries works and what and how ld.so does, but that seemed to get very long. So here the short version that assumes pre-existing knowledge.

    If you want an RPATH in your DSOs (dynamic shared objects: executables and …

  5. Mocking away the .__init__() method

    I wanted to test a method on a class that didn't really depend on a lot of other stuff off the class. Or rather what it did depend on I had already turned into Mock objects with appropriate .return_value and asserting with .called etc. Problem was that the .__init__() method …

  6. Preserving modification times in subversion

    This is an oft requested feature apparently. But who know if and when it will be there. Usually things get done when someone has an itch to scratch, but given that no one has done this yet -but it's been requested for ages- it seems that it must either be …

  7. Generative Tests

    Both nose and py.test allow you to write generative tests. These are basically generators that yield the actual test functions and their arguments. The test runners will then test all the yielded functions with their arguments.

    However I'm left wondering why this is better then just iterating in the …

  8. Solaris equivalent of dpkg -S

    In the past I have spent quite some time trying to figure out what package did install a certain file on Solaris. What I wanted was really just the equivalent of dpkg -S /path/to/file. But those searches where not very fruitfull, even talking to more experienced Solaris admins …

  9. Bluetooth on a Toshiba Tecra A9-127

    I got a Toshiba Tecra A9-127, listening to the model number of PTS52E-06002LEN as written on the back, from work to replace my dying old HP Compaq nx9030. As my laptop OS of choice is Ubuntu, currently in it's Hardy release, it's not completely coincidence that the hardware is almost …

  10. Ripping videos from DVD

    Physical discs are a nuisance, I really just want to play what I want to watch in the room I want to watch it just streaming it over the wireless. This actually works wonderfully well. Unfortunately just copying the file structure of a DVD works and gives you DVD-quality video …

  11. Time to read standards

    Sometimes I like quotes out of context...

    Anyway, I don't think it really is an ambiguity in practice — only in the minds of those that have too much time to read standards documents.

    —Greg Ewing (on distutils-sig)

  12. @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 …
  13. (O)OXML and ISO voting processes

    Many have recently complained about ISO's voting processes, mainly how they need to be revised as currently it seems it's possible to buy yourself a standard given enough lobbyist and money.

    But part of this is ISO's trust in ECMA. ISO allows ECMA to submit standards for the fast-track process …

  14. Shell history

    hehe

    flub@signy:~$ history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn |head
    79 nosetests
    74 ls
    46 cd
    36 ssh
    28 man
    22 apt-cache
    19 vi
    19 ack
    17 svn
    17 sudo
    flub@signy:~$
    

    It must be noted that most of my editing …

  15. 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 …

  16. One s3fs to rule them all?

    Sometimes I wish we could fast forward 6 or 12 months or so. Hopefully by then there will be just one s3fs that is mature and maintained. Right now it's hard to tell which one will turn out the best.

    Interstingly, of the ones that look like they could have …

  17. 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 …

  18. Cheating the KAME turtule

    This is shocking. Even though I have not yet used IPv6 I can see the the KAME turtle dance! I won't give you a direct link but SixXS privde an IPv6->IPv4 service as well as an IPv4->IPv6 service. Feels bad having used the 4->6 bit... </p>

  19. OmniORB 4.1.1 in lenny!

    Something that happened about a week ago I think. But omniORB 4.1.1 finally make it into Debian testing aka lenny! This means that python-omniorb 3.1, which has been waiting for a while now, also make it into lenny!

    It has been stalled for ages since we had …

  20. Compiling libtool examples

    This is more a reminder to myself, but here's how to compile the libtool examples:

    $ cd demo
    $ aclocal
    $ libtoolize --automake
    $ automake --add-missing
    $ autoconf
    $ ./configure
    $ make
    

    It's really how to bootstrap any GNU autotools using application I suppose.

  21. My favourite package description

    This sentence in a package description is always great...

    You probably don't need it if you don't understand what this is all about.

    Brought to you today by nut-snmp but can be found in many other packages.

  22. Another shell trick

    Let's start with the solution instead of the problem:

    myvar=$(myfunc) || exit $?
    

    Assuming myfunc is a function defined elsewhere in your shell script this will execute that function and assign it's output to myvar. However when myfunc fails, the entire assignment statement fails with the exit status of myfunc, so …

  23. 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 …

  24. 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 …
  25. Paradox

    Creating a Facebook group to complain about the UK ID cards because:

    [...] An ID card would hold ALL personal information about you including biometrics, hospital records etc etc., a perfect target for ID thieves. [...]

    And you're doing this on Facebook?

  26. Mild improvement for movie industry

    Until now every time I bought a DVD I found a few scary and angry leaflets in the box telling me how insanely bad I might be for buying pirated DVDs. They usually convince you that you are the worst person in the world for no particular reason. So just …

  27. Rock climbing in Costa Daurada

    Just spent a long week sport climbing in Costa Daurada. We stayed in a house (with about 32 students and ex-students) near the village of Cornudella de Montsant which was an excellent location really close to Siurana and Arboli. Absolutely brilliant climbing and although my brain wanted to stay a …

« Page 4 / 7 »