小编IFC*_*CZT的帖子

Python继承类方法的一些问题

我有这个代码:

from typing import Callable, Any


class Test(classmethod):
    def __init__(self, f: Callable[..., Any]):
        super().__init__(f)

    def __get__(self,*args,**kwargs):
        print(args)  # why out put is (None, <class '__main__.A'>) where form none  why no parameter 123
        # where was it called
        return super().__get__(*args,**kwargs)


class A:
    @Test
    def b(cls,v_b):
        print(cls,v_b)

A.b(123)
Run Code Online (Sandbox Code Playgroud)

为什么输出是(None, <class '__main__.A'>)?它是从哪里来的?None为什么它不是我调用它的参数 123

python class-method

5
推荐指数
1
解决办法
89
查看次数

标签 统计

class-method ×1

python ×1