Table of Contents
The load
function in Python is used to import a module, a file containing Python code, from the file system.
Syntax:
pythonload(module_name)
Parameters:
module_name
: The name of the module to be loaded. This can be a package or a Python module file.Example:
“`python
import math
print(math.pi)print(math.sqrt(2))“`
Output:
3.141592653591.41421356237
Notes:
load
function is considered deprecated in Python 3 and replaced with the import
statement.load
function can also be used to load a module from a particular path. For example:“`python
load(‘/home/user/my_module.py’)“`
Equivalent Import Statement:
“`pythonimport math
import math“`
Therefore, the load
function is primarily used in older Python code and is not recommended for use in new code.
Table of Contents
Categories