Fork me on GitHub
  1. Afficher les données de Paris OpenData avec polymaps

    En ouvrant l'accès à un catalogue de données diverses (Équipements, bâti, arbres d'alignement, arrêtés municipaux, ...) l'initiative ParisData, l'Open Data de la capitale, nous donne l'occasion de manipuler des données georéférencées. Notre objectif ici sera de les publier sur une page Web grâce à un outil simple et léger : polymaps.

    Transformation …

    read more

    There are comments.

  2. Python UTF-8 print fails when redirecting stdout

    Consider the following piece of code:

    # -*- coding: utf-8 -*-
    print u"Վարդանաշեն"
    

    Running this in a terminal works:

    $ python test.py
    Վարդանաշեն
    

    Redirecting standard output to a file fails:

    $ python test.py > file
    Traceback (most recent call last):
      File "test.py", line 2, in <module>
        print u"Վարդանաշեն"
    UnicodeEncodeError: 'ascii' codec …
    read more

    There are comments.

  3. Python lazy hasattr()

    Python hasattr() evaluates the specified attribute, which may not be desired !

    class Attr(object):
        def __get__(self, obs, cls=None):
            print "evaluated"
            return 0
    
    class ClassA(object):
        a = Attr()
    
        @property
        def b(self):
            print "evaluated"
            return 0
    
    >>> c = ClassA()
    >>> c.a
    evaluated
    0
    >>> c.b
    evaluated
    0
    

    Now note that …

    read more

    There are comments.

  4. Filesystem Watch with PyQt4

    I decided to write a generic program that can watch a folder or some files and run a command when changes occur.

    Most of the work is done by PyQt4's QFileSystemWatcher.

    qfsw = QtCore.QFileSystemWatcher()
    qfsw.addPaths([path1, file2 ... ])
    
    QtCore.QObject.connect(qfsw,QtCore.SIGNAL("directoryChanged(QString)"),function)
    QtCore.QObject.connect …
    read more

    There are comments.

« Page 2 / 3 »

social