Python Command Line
Tips for the Python Command Line in Unreal
importlib.reload
When developing Unreal Python tools I regularly using the Python input on the Output Log Window:

We don't always need to relaunch Unreal to try out a few changes to a module's logic, in the Output Log window we can run importlib.reload:
from importlib import reload
from demo import bp_library
reload(bp_library)
# Result: Display: Reload/Re-instancing Complete: 1 class changed
This will even reload Blueprint Function libraries, although caution is advised to make sure you're updating the BP Graph / any downstream dependencies for your code development.
Pre-Loaded modules / libraries
If you find yourself constantly using the same modules in the Output Log's Python command line, we can make them available by default in one of two ways.
Python Project Settings
The first method is to add our imports to the Project Setting's Python section, anything in there will be accessible from the Python command line in the Editor:

init_unreal.py
Another method is with an init_unreal.py file, any imports, classes, or functions declared in one of these files will also be added to the main namespaces accessible from the Python command line in the Editor:

results
Both options will load these modules/functions for us, making them accessible right away in the Python command line:

Last updated