Created
January 15, 2010 10:13
-
-
Save shelling/277944 to your computer and use it in GitHub Desktop.
show how to write a class method in Python
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 Hello(): | |
| def world(self): | |
| return "world" | |
| world = classmethod(world) | |
| def foo(): | |
| return "foo" | |
| foo = staticmethod(foo) | |
| @classmethod | |
| def bar(): | |
| return "bar" | |
| print Hello.world() | |
| print type(Hello.world) | |
| print type(classmethod) | |
| print Hello.foo() | |
| print Hello.bar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment