0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【python】メソッド(&引数)とフィールド(&値)一覧を取得するやつ

Last updated at Posted at 2024-07-22

メソッドとフィールド値を表示するやつがあると便利だとたびたび思ってたからメモ

import inspect
for mem,v in inspect.getmembers(object):
    if inspect.isfunction(mem):
        v=inspect.signature(mem)
    print(mem,':',v)

2024/07/26追記
strする必要があったっぽい

import inspect
for mem,v in inspect.getmembers(object):
    if inspect.isfunction(mem):
        v=str(inspect.signature(mem))
    print(mem,':',v)
0
0
1

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?