Having worked in a variety of other languages, my first instinct was to create classes with static methods for things like utility libraries. But after digging around Google for a bit, it seems like this isn’t necessarily the way things are done in Python:
http://stackoverflow.com/questions/12735392/python-class-static-methods
I’m not sure where I stand on this just yet. The logical argument is that classes should only be used for when you need to instantiate something. But sometimes it’s handy to make use of class variables. And really the only difference is a small change in syntax:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import filename | |
filename.foo() | |
from filename import ClassName | |
ClassName.foo() |