5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pythonでモジュール名とクラス名の取得のサンプル

Posted at
# -*- coding: utf-8 -*-

class Test(object):

    @classmethod
    def class_method(cls):
        print "cls.__module__", cls.__module__
        print "cls.__name__", cls.__name__

if __name__ == "__main__":
    Test.class_method()

出力結果

cls.__module__: __main__
cls.__name__: Test
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?