我有一个奇怪的问题.我有以下代码:
class A:
def f():
return __class__()
class B(A):
pass
a = A.f()
b = B.f()
print(a, b)
Run Code Online (Sandbox Code Playgroud)
输出是这样的:
<__main__.A object at 0x01AF2630> <__main__.A object at 0x01B09B70>
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能获得B而不是第二A呢?
我正在用 Sphinx 记录我的图书馆。我有装饰器logic_object:
class logic_object:
"""Decorator for logic object class.
"""
def __init__(self, cls):
self.cls = cls
self.__doc__ = self.cls.__doc__
Run Code Online (Sandbox Code Playgroud)
我有gravity一个由以下人员装饰的课程logic_object:
@logic_object
class gravity:
"""Basic gravity object logic class.
:param float g: pixels of acceleration
:param float jf: jump force
"""
#There is more not important code.
Run Code Online (Sandbox Code Playgroud)
我的狮身人面像.rst文件是:
Mind.Existence
========================
Classes, methods and functions marked with * aren't for usual cases, they are made to help to the rest of the library. …Run Code Online (Sandbox Code Playgroud)