Skip to content

Instantly share code, notes, and snippets.

@fereria
Created June 9, 2016 04:27
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 fereria/60ff8bf9241f9bb5a51629029379019e to your computer and use it in GitHub Desktop.
Save fereria/60ff8bf9241f9bb5a51629029379019e to your computer and use it in GitHub Desktop.
get class name
# -*- 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