Note:
In addition, you can look at the standard Python documentation on the official Python website (http://www.python.org) for a list of built-in functions. Built-in functions are described in the Built-in Functions section of the Python Library Reference. Many functions, however, are not built-in; for example, most of the math
functions, such as import sys for argument in sys.argv: print(argument) You must first import the module to make its functions, names, and functionality available to the Python interpreter. Try the following: >>> from math import * >>> x = pi/4.0 >>> sin(x) 0.707106781187 The first line imports all of the names from the
To import only the >>> from math import sin You need to import a module only once during a session. Once a module is imported, its functions, methods, and attributes are always available to you. You cannot unload a module after you import it. To see a list of all the functions that come with the
Python provides a second approach to importing modules. For example, >>> import math >>> x = 22.0/(7.0 * 4.0) >>> math.sin(x) 0.707330278085 The import approach shown above imports the module as a unit,
and you must qualify the name of an object from the module. To access a
function from the What is the difference between the two approaches to importing modules? If two modules contain an object with the same name, Python cannot distinguish between the objects if you use the from modulename import * approach. If two objects have the same name, Python uses the object most recently imported. However, if you use the import modulename approach, modulename qualifies the name of the object and makes it unique. |