Tag Archives: python

ipython autocompletion does not work

With IPython version 7.12.0 and python 3.7.3, Ipython crashes when I wanted to autocomplete a file or a module import. This fixed my problem: pip install pyreadline An the jedi package was set to 0.18.0 but this seems to cause … Continue reading

Posted in Computer Science | Tagged , | Leave a comment

How to use subprocess with PIPEs

In Python, the subprocess module allows you to execute linux/unix commands directly from Python. The official Python documentation is very useful would you need to go further. Yet it may be a bit scary for newbies. Syntax may also change … Continue reading

Posted in Python | Tagged , | 1 Comment

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 , , | 12 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()

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 | 35 Comments