When calling rixpress()
, a file containing Python import statements is
automatically generated inside the _rixpress
folder. For example, if the
numpy
package is needed, the file will include a line like
"import numpy"
. However, Python programmers often write
"import numpy as np"
instead.
Details
In some cases, the correct import statement is entirely different. For
example, for the pillow
package, the generated file will contain
"import pillow"
, which is incorrect—Python code should import from the
PIL
namespace instead, e.g., "from PIL import Image"
.
Because these adjustments cannot be automated reliably, the adjust_import()
function allows you to search and replace import statements programmatically.
It reads each file in the _rixpress
folder, performs the replacement, and
writes the modified content back to the file.
See also
Other python import:
add_import()