So I have a common module which contains processing functions for numbers and types of data I am using. I want to be able to include it like from common import common (or better yet just import common) and use functions like common.howLongAgo(unixTimeStamp)
What is required to do this in my common module?. Common is a module consisting of a class ‘common’.
Ways of exposing methods in a python module:
module
foo.py:now, importing:
If you want to make class method more useful, import the class directly:
You can also
import ... as ...to make it more readable:Which ones you should use is somewhat a matter of taste. My personal rule of thumb is: