Introduction Python#

The idea of this documentation is to list useful general tips and tricks for python.

Hevs SPL Python Library#

The purpose of this library is to regroup general/common python functions or classes in the same place in a way that they are easily shared and used by the SPL team.

Feel free to had any python functions/classes as long as they are not very specific to a project.

Guidelines#

If you extent the Hevs SPL Python Library try to follow the following rules as much as possible to keep a good consistency in the library:

  • use camelCase for functions names

  • use snake_case for variables names

  • use _snake_case with and underscore at the beginning for private variables names

  • use ALL_CAPS for constant names

  • use CapWords for class names

We also try to follow the Google Python Styleguide

DocStrings#

Classes and function in the Hevs SPL Python Library require a proper docstring in the Google Style Docstring format.

def createDir(directory):
    """Checks if directory exists, and creates it if not

    Note:
        Do not include the `self` parameter in the ``Args`` section.
    Args:
        dir: string location of directory
    Returns:
        None
    Raises:
        NotADirectoryError
    """
    if (os.path.exists(directory)) is False:
        os.makedirs(directory)
    if (os.path.isdir(directory)) is False:
        raise NotADirectoryError("{} is not a directory".format(directory))

Referenced Python samples#

Python