Skip to main content

Timeline for Classes vs. modules in Python

Current License: CC BY-SA 4.0

8 events
when toggle format what by license comment
Nov 1, 2019 at 7:02 comment added Turksarama @ProQ In languages like Python where you can have functions in modules rather than classes (as opposed to, say, Java) it's generally good form to just keep static functions at the module level. Classes imply instances with their own state.
S Jan 10, 2019 at 0:22 history suggested Considerate CC BY-SA 4.0
Improved grammar and added more links.
Jan 9, 2019 at 12:19 review Suggested edits
S Jan 10, 2019 at 0:22
Dec 13, 2018 at 12:12 comment added multigoodverse Modules don't always reside in a folder with a __init__.py file.
May 11, 2018 at 0:59 vote accept Pro Q
Aug 26, 2016 at 2:24 comment added Eneko Alonso You can create multiple instances of a class, but you cannot create instances of a module. You could compare modules to static classes or singletons.
Aug 25, 2016 at 23:48 comment added Pro Q So it's not a bad thing to have a single class in a module, even if that class only has functions? I feel like in that situation I should generally just make a module without making a class. Is there an underlying rule as to when to use classes instead of modules? (That's what I'm trying to ask... Should I edit my question to make it more clear?)
Aug 25, 2016 at 22:40 history answered Eneko Alonso CC BY-SA 3.0