Other Built-in Modules
This section documents a handful of additional built-in modules. See the Python Library Reference for details on all built-ins and the Vaults of Parnassus web site at http://www.vex.net/parnassus/ for third-party modules and tools.
The math Module
The math
module exports C standard math library
tools for use in Python. Table 1-24 lists this
module’s exports; see the Python Library Reference for more
details. Also see the cmath
module for complex
number tools and the NumPy system for advanced
numeric work. frexp
and modf
return two-item tuples for a single argument.
Table 1-24. math module exports
pi |
e |
acos(
|
asin(
|
atan(
|
atan2( |
ceil(
|
cos(
|
cosh(
|
exp(
|
fabs(
|
floor(
|
fmod( |
frexp(
|
hypot( |
ldexp( |
log(
|
log10(
|
modf(
|
pow( |
sin(
|
sinh(
|
sqrt(
|
tan(
|
tanh(
|
The time Module
Following is a partial list of time module exports. See the Python Library Reference for more details.
clock( )
Returns the current CPU time as a floating-point number expressed in seconds (CPU time for process so far). Useful for benchmarking and timing code sections.
ctime(secs)
Converts a time expressed in seconds since the epoch to a string representing local time (e.g.,
ctime(time( ))
). As of 2.1, the argument is optional and defaults to the current time if omitted.time( )
Returns a floating-point number representing UTC time in seconds since the epoch. On Unix, epoch is 1970.
sleep(secs)
Suspends the process’s execution for ...
Get Python Pocket Reference, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.