Chapter 3. userconfig

userconfig is your personal configuration file for all things concerning Python in Kahakai, which basically boils down to key and mouse bindings. At the time being, you'll almost definitely be using userconfig.py, but as Ruby support matures (and Ruby users spring up), you may very well be using userconfig.rb, or even another language in the future. For now the docs mostly focus on Python.

3.1. imports

The first thing done in userconfig.py (and generally all Python scripts) is importing of other modules. A Python module is just a file containing Python code; you import it by using the import Python keyword. The name of the module is the same as the name of the file, with the .py chopped off the end. You can learn more about how python modules work in the Python tutorial.

So now let's take a look at what we're importing.

from actions import install
from macros import *

What this means is that we are importing the function install from actions.py, and importing everything from macros.py. Using the from modulename import foo syntax imports everything from modulename into the global namespace of the current file, with the exception of any names starting with an underscore. Thus, things like Ctrl, KeyPress(), and screen() all come from macros.py, and are available to us in userconfig.py.