> I don't understand why sqrt is not a built-in function.
> Why do we have to first import the function from the math module?
> I use it ALL THE TIME!

For one, it's specific to numeric types. You might use it all the
time, but I (for example) almost never need to use it, or to import
the math module for my Python work/play. OTOH, I use stuff from the
sys and csv modules (and lately, pandas) all the time. I import those
modules when necessary. If you don't need them, I suspect you might
grumble that they are useless for you. Requiring explicit module
import gives programmers more control over the content of their module
namespaces if the builtins don't include the kitchen sink.

If you skim the output of

import builtins
dir(builtins)

you should see that the two largest classes of builtin identifiers are
exceptions (ZeroDivisionError, etc) and types (list, set, etc). Other
classes include singleton constants (True, False, None) and general
sequence operations (useful for loop control - reversed, iter,
zip...). math.sqrt doesn't fit into those object classes. The
remainder are a mixture of things, but generally aren't quite as
special purpose as that. Granted, there are a couple which might be
better left out (IMO), like round and pow, but I suspect their
presence might simply be more a matter of them being present since
Python's earliest days and reflect a tendency later to avoid
gratuitous breakage of existing code.

Finally, should have never considered it, I think you might want to
study the output of

import this

Think on the second and last lines in particular.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to