Created
September 7, 2016 16:44
-
-
Save rogthefrog/511adf14041c621bf39147e836fa9b91 to your computer and use it in GitHub Desktop.
Class method v. module
This file contains hidden or 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 module | |
from classmethod import Thing | |
Thing.do_the_thing() | |
module.do_the_thing() |
This file contains hidden or 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
class Thing(object): | |
attr = "hello" | |
@classmethod | |
def do_the_thing(klass): | |
print "doing the thing", klass.attr |
This file contains hidden or 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
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