Ask coding questions

← Back to all posts
How to modules? In python
YvngBashit (13)

So I have been learning python and what interests me the most are modules. But the problem is I don't know how to use them?

JoshDaBosh (77)

You would need to import them. For example, to use the time module, you'd do:

import time

and you could use it's functions like time.time(), time.sleep(), etc etc

ash15khng (576)

Modules are basically allowing code from other files being used in another file. For example: import time imports the time module, allowing all of the functions in time to be used. To use a function from a module when you import a module as import modulename, use modulename.functionname(arg1, arg2="abcdefg")