Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created August 29, 2008 02:48
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 jugyo/7885 to your computer and use it in GitHub Desktop.
Save jugyo/7885 to your computer and use it in GitHub Desktop.
class Test:
@classmethod
def test(self):
""" クラスメソッド
"""
print 'test'
@classmethod
def test2(self):
""" クラスメソッド2
プライベートなクラスメソッドを呼び出す
"""
print 'test2'
self.__test()
@classmethod
def __test(self):
""" プライベートなクラスメソッド
"""
print '__test'
Test.test()
Test.test2()
Test.__test()
""" 実行結果
$ python class_method_test.py
test
test2
__test
Traceback (most recent call last):
File "import_test_lib.py", line 26, in <module>
Test.__test()
AttributeError: class Test has no attribute '__test'
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment