Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are math.py and sys.py?

I found all the other modules in Python33/Lib, but I can't find these. I'm sure there are others "missing" too, but these are the only ones I've noticed. They work just fine when I import them, I just can't find them. I checked sys.path and they weren't anywhere in there. Are they built-in or something?

like image 332
temporary_user_name Avatar asked Sep 17 '13 18:09

temporary_user_name


People also ask

Where is Python sys module?

It's in Python/Python/sysmodule.

What package is math in Python?

math is a built-in module in the Python 3 standard library that provides standard mathematical constants and functions. You can use the math module to perform various mathematical calculations, such as numeric, trigonometric, logarithmic, and exponential calculations.

How do you access the math module in Python?

The math module is a standard module in Python and is always available. To use mathematical functions under this module, you have to import the module using import math . This module does not support complex datatypes.

Is sys a library in Python?

The sys module in Python provides various functions and variables that are used to manipulate different parts of the Python runtime environment. It allows operating on the interpreter as it provides access to the variables and functions that interact strongly with the interpreter.


1 Answers

The math and sys modules are builtins -- for purposes of speed, they're written in C and are directly incorporated into the Python interpreter.

To get a full list of all builtins, you can run:

>>> import sys
>>> sys.builtin_module_names

On my machine, that results in the following list:

__builtin__
__main__
_ast
_bisect
_codecs
_codecs_cn
_codecs_hk
_codecs_iso2022
_codecs_jp
_codecs_kr
_codecs_tw
_collections
_csv
_functools
_heapq
_hotshot
_io
_json
_locale
_lsprof
_md5
_multibytecodec
_random
_sha
_sha256
_sha512
_sre
_struct
_subprocess
_symtable
_warnings
_weakref
_winreg
array
audioop
binascii
cPickle
cStringIO
cmath
datetime
errno
exceptions
future_builtins
gc
imageop
imp
itertools
marshal
math
mmap
msvcrt
nt
operator
parser
signal
strop
sys
thread
time
xxsubtype
zipimport
zlib
like image 104
Michael0x2a Avatar answered Sep 28 '22 07:09

Michael0x2a