pylab_ml.common.environment.path_insert

path_insert(self, path, check=True, append=False)[source]

Insert a path into sys.path if it does not already exist.

eg. path_insert(‘/path/to/directory’, check=True, append=False) will insert the specified path at the beginning of sys.path if it does not already exist and if the path exists on the filesystem. If check is False, it will insert the path without checking if it exists. If append is True, it will insert the path at the end of sys.path instead of the beginning.

Parameters:
  • path (str) – The path to be inserted into sys.path.

  • check (bool, optional) – If True, insert only if the path does not exist in sys.path. Default is True.

  • append (bool, optional) – If True, insert the path at the bottom of sys.path. Default is False.

Returns:

True if the path was successfully inserted or already exists, False otherwise.

Return type:

bool