[Tutor] math, cmath and all that ... [module.__file__]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu, 8 Aug 2002 17:52:31 -0700 (PDT)


> > Where is the module math? Or what is its special character? It's not
> > in Lib (as for instance string), but its also not built-in. Like
> > cmath, os, sys, ... ? [Perhaps it is, that they are written in C, do
> > they constitute dlls or what?]


By the way, we can ask a module which file it belongs to:

###
>>> import math
>>> math.__file__
'/opt/Python-2.1.1/lib/python2.1/lib-dynload/math.so'
###

So yes, the 'math' module isn't written in Python itself, but is an
extension module written in C.  '.so' is an extension used on Unix systems
to say that these are dynamically linked libraries.  (".so" stands for
"shared object")  On a Windows system, we'll probably see something like
'math.dll' instead.


Hope this helps!