Class like modules? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Class like modules?

Is a class the same as a module? Since a class is a group of related functions inside a container? Can we say that they are the same or not? ex: with the random module --> random = Class randint = method of the random "class" choice = method of the random "class" So is it the same? If not , can we use it as it it was that? PS: Im new to oop

15th Nov 2016, 10:15 PM
Z00M
1 Antwort
+ 1
class is not a module, but module can be a class. modules can contain classes, functions, constants, anything else. they are the same pieces of code. difference is that you don't write everything in one script, instead you write logical parts of your code as reusable modules and import them to your main script.
16th Nov 2016, 4:49 PM
Demeth
Demeth - avatar