O'Reilly logo

Python Pocket Reference, 4th Edition by Mark Lutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Other Standard Library Modules

This section documents a handful of additional standard library modules. See the Python Library Reference for details on all built-in tools, and the PyPI websites (described in Assorted Hints) or your favorite web search engine for third-party modules and tools.

The math Module

The math module exports C standard math library tools for use in Python. Table 1-25 lists this module’s exports; see the Python Library Reference for more details. Also see the cmath module in the Python library for complex number tools and the NumPy system for advanced numeric work.

Table 1-25. math module exports in Python 3.0 and 2.6

acos

acosh

asin

asinh

atan

atan2

atanh

ceil

copysign

cos

cosh

degrees

e

exp

fabs

factorial

floor

fmod

frexp

fsum

hypot

isinf

isnan

ldexp

log

log10

log1p

modf

pi

pow

radians

sin

sinh

sqrt

tan

tanh

trunc

   

The time Module

Following is a partial list of time module exports. See the Python Library Reference for more details.

clock()

Returns the CPU time or real time since the start of the process or since the first call to clock(). Precision and semantics is platform-dependent (see Python manuals). Returns seconds expressed as a floating-point number. Useful for benchmarking and timing alternative code sections.

ctime(secs)

Converts a time expressed in seconds since the epoch to a string representing local time (e.g., ctime(time())). 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required