Created
June 9, 2016 04:27
-
-
Save fereria/60ff8bf9241f9bb5a51629029379019e to your computer and use it in GitHub Desktop.
get class name
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
# -*- coding: utf-8 -*- | |
def test_val(func): | |
def _func(*args, **kwargs): | |
# クラス名 | |
# クラスの関数の1つ目の引数はClass自身=selfなので | |
# そこからクラス名を取得する | |
print args[0].__class__.__name__ | |
return func(*args, **kwargs) | |
return _func | |
class TEST(object): | |
@test_val | |
def test_func(self): | |
print "hello world" | |
a = TEST() | |
a.test_func() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment