in_directory class

(Shortest import: from brian2.utils.filetools import in_directory)

class brian2.utils.filetools.in_directory(new_dir)[source]

Bases: object

Safely temporarily work in a subdirectory

Usage:

with in_directory(directory):
    ... do stuff here

Guarantees that the code in the with block will be executed in directory, and that after the block is completed we return to the original directory.