How do you print a module name in Python?
I tried to import a module and print it, then it gives me <module 'time' (built-in)>.
import time
print(time) # <module 'time' (built-in)>
How to print just the module name?
The name of a module as a string is available as its __name__ attribute.
>>> import time
>>> print(time.__name__)
time
This is shown in the Tutorial, by the way.
Simply import a module and print its name using _name
dir(x), e.g.dir(time). In this case you would see that is has a__name__attribute