>>> def hehe():
... return "spam"
...
>>> repr(hehe)
'<function hehe at 0x7fe5624e29b0>'
私が持っていると思います:Python関数の表現を変更するにはどうすればよいですか?
>>> repr(hehe)
'hehe function created by awesome programmer'
私はそれをどのように行うのですか? __repr__
をhehe
の中に入れても機能しません。
編集:私はこれをしたい理由の場合
は皆さんが思っている:
>>> defaultdict(hehe)
defaultdict(<function hehe at 0x7f0e0e252280>, {})
私はちょうどそれがここに示した方法が好きではありません。
なぜあなたはしたいですか?彼の? –
私はあなたの質問に私の質問で答えました。 – vajrasky