Skip to content

Instantly share code, notes, and snippets.

@rogthefrog
Created September 7, 2016 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogthefrog/511adf14041c621bf39147e836fa9b91 to your computer and use it in GitHub Desktop.
Save rogthefrog/511adf14041c621bf39147e836fa9b91 to your computer and use it in GitHub Desktop.
Class method v. module
import module
from classmethod import Thing
Thing.do_the_thing()
module.do_the_thing()
class Thing(object):
attr = "hello"
@classmethod
def do_the_thing(klass):
print "doing the thing", klass.attr
attr = "here"
def do_the_thing():
print "doing the thing with", attr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment