What is python’s site-packages directory?

site-packages is the target directory of manually built Python packages. When you build and install Python packages from source (using distutils, probably by executing python setup.py install), you will find the installed modules in site-packages by default. There are standard locations: Unix (pure)1: prefix/lib/pythonX.Y/site-packages Unix (non-pure): exec-prefix/lib/pythonX.Y/site-packages Windows: prefix\Lib\site-packages 1 Pure means that the module uses only Python code. Non-pure can contain C/C++ code as well. site-packages is by default … Read more

Syntax highlighting in vim for python

The command to enable syntax highlighting in vim is :syntax on, if you want it to be active everytime you launch vim, just add a line containing syntax on in your .vimrc file.

TypeError: got multiple values for argument

This happens when a keyword argument is specified that overwrites a positional argument. For example, let’s imagine a function that draws a colored box. The function selects the color to be used and delegates the drawing of the box to another function, relaying all extra arguments. Then the call will fail because two values are … Read more

Building a list inside a list in python

You could append empty lists until you have enough to access the index you have data for: However, you may want to use a dictionary instead, letting you implement a sparse object instead. A collections.defaultdict() object is especially useful here: data now has keys 2 and 5, each a list with one element. No entries … Read more

Random word generator- Python

Reading a local word list If you’re doing this repeatedly, I would download it locally and pull from the local file. *nix users can use /usr/share/dict/words. Example: Pulling from a remote dictionary If you want to pull from a remote dictionary, here are a couple of ways. The requests library makes this really easy (you’ll … Read more