Two notes about Lab Class 8 - Python DB Application Development and Transactions

24 janeiro 2022, 19:29 Bruno Emanuel Da Graça Martins

NOTE 1 - When saving the files corresponding to .cgi scripts, make sure to encode line endings using the UNIX-like pattern (only with the line feed control character – LN), instead of the Windows pattern (carriage return followed by line feed – CR-LF). Using the incorrect encoding for line endings will produce an error when executing the scripts. Most text editors will allow you to select the encoding for line endings (e.g., on Notepad++, double click on the EOL format shown in the status bar and select Unix(LF)). You can also edit the scripts directly on the sigma cluster, using an editor of your choice: pico, vi, emacs, joe, ...

NOTE 2 - In Python scripts, by default, you can only import a file (e.g., login.py) in the directory where the entry-point script is running from, and from sys.path (which includes locations such as the package installation directory). However, you can add other directories to the Python path at runtime, as shown in the next example.

import sys
sys.path.insert(1, '/path/to/folder-containing-files-to-import')
import myfile