0
Difference between modules and class
I have learned classes and modules Both modules and classes contain functions and we can use class's functions with the classname.function or object.function and we can use functions from modules by importing it. So what's is the main difference between them
1 Answer
+ 1
You can make many objects out of a single class:
class Foo:
def __init__(self, name):
self.name = name
joseph = Foo("Joseph")
charles = Foo("Charles")
mary = Foo("Mary")
print(charles.name) # prints `Charles`
Modules, on the other hand, are meant to be imported once.