我正在制作一个 wxPython 应用程序,它为用户提供一个 shell。(这是wx.lib.shell.PyShell
wxPython 附带的 shell。)
问题是,在这个 shell 中定义的.__module__
属性不好。例如:
>>> def f(): 0
...
>>> f.__module__
>>> f.__module__ is None
True
>>> class A(object):
... pass
...
>>>
>>> A.__module__
'__builtin__'
我认为.__module__
这两个对象的属性应该是__main__
. 没有把握。但绝对不应该是None
or __builtin__
。
如何让 shell.__module__
为这些函数和类赋予良好的属性?