Tag Archives: python

How to get pypi statistics about package download

A while ago, I designed pypiview, a Python package used to fetch the number of downloads for a package hosted on pypi website. It used to work decently but according to pypi itself the values stored are not reliable and … Continue reading

Posted in Python | Tagged , , , | Leave a comment

Difference between __repr__ and __str__ in Python

When implementing a class in Python, you usually implement the __repr__ and __str__ methods. __str__ should print a readable message __repr__ should print a message that is unambigous (e.g. name of an identifier, class name, etc). You can see __str__ … Continue reading

Posted in Python | Tagged , | 3 Comments

pytest-cov collects no data on Travis

I recently switched from nosetests to pytest and pytest-cov for one of my Python project (http://easydev-python.readthedocs.io). Locally, everything seemed to work fine and once on Travis, all tests passed as expected. Yet, before the coverage report, I noticed this warning: … Continue reading

Posted in Python | Tagged , , | 11 Comments

Installing Python2.6 in a virtual environment

First, install python2.6 executable. see previous post if you have issues when compiling (gcc not found). Make sure you have installed python-dev with apt-get or yum. Then, following the instructions on the same topic but for Python 3 in a … Continue reading

Posted in Python, Software development | Tagged , | 2 Comments

Installation of Python 2.6 error fixed

I wanted to install python2.6 in a virtual environment. The first step was to compile python 2.6 executable from the source code. Once the source are extracted, just type: ./configure –prefix=<PATH_WHERE_TO_INSTALL> make./configure –prefix=<PATH_WHERE_TO_INSTALL> make If you are lucky, everything is … Continue reading

Posted in Python | Tagged , | 11 Comments

Python function chmod to change permission

I naively tried the function chmod from the standard python module called os to change the permission of a file: os.chmod(filename, 644)os.chmod(filename, 644) Checking in the unix command line (ls -l), I got an unexpected result: –w—-r-T.–w—-r-T. I expected indeed … Continue reading

Posted in Python | Tagged | 2 Comments

Python : How to flush output of print

Using the sys module, just type: import sys sys.stdout.flush()import sys sys.stdout.flush() Please follow and like us:

Posted in Python | Tagged | Leave a comment

python argparse issues with the help argument (TypeError: %o format: a number is required, not dict)

Even though Python has a great documentation, once in a while you get stuck on a single problem more than expected. It happenned to me today with the argparse module, which I thought I knew enough to quickly code a … Continue reading

Posted in Python | Tagged | 28 Comments

Starting to use Python Pandas library

Pandas is brilliant. If you are looking to manipulate data in Python, use it. I am refactoring most of my codes with this library. It provides many useful data structures to manipulate data in 2, 3, 4 dimensions and more. … Continue reading

Posted in Python | Tagged , | Leave a comment

Line starting ‘ …’ is malformed! error

Playing with a Python wrapper of an R package, I suddenly got this error after a trivial change of the code: Line starting ‘<!DOCTYPE html> …’ is malformed!Line starting ‘<!DOCTYPE html> …’ is malformed! Wondering for a couple of minutes … Continue reading

Posted in R | Tagged , , | Leave a comment