小编Jer*_*mie的帖子

python中的多个赋值

我在这里需要一个明确的解释.为什么以下代码有效?

foo1 = foo1[0] = [0]
Run Code Online (Sandbox Code Playgroud)

好的,我知道作业是从左到右完成的.

python如何理解foo1列表?

顺便说一句,我知道它foo1最终是[[...]]它的第一个元素.

python

26
推荐指数
1
解决办法
1604
查看次数

Python 3.6:我想念一些泛型打字超链接继承

首先,我运行以下代码,这真的很好:

class Monster:
    def __init__(self):
        self._can_do = []
        print("created a monster")
        super().__init__()

class Race(Monster):
    """ all races must derive from this """
    def __init__(self):
        super().__init__()
        print("created a race x")

class Human(Race):
    def __init__(self):
        super().__init__()
        self._can_do.append("Do nothing special !")
        print("created a human")

class Elf(Race):
    def __init__(self):
        super().__init__()
        self._can_do.append("Avoid sleep")
        print("created an elf")

class Class:
    """ all classes must derive from this """
    def __init__(self):
        super().__init__()
        print("created a class x")

class Fighter(Class):
    def __init__(self):
        super().__init__()
        self._can_do.append("Hit hard")
        print("created a fighter")

class Wizard(Class): …
Run Code Online (Sandbox Code Playgroud)

python generics inheritance typing super

3
推荐指数
1
解决办法
83
查看次数

标签 统计

python ×2

generics ×1

inheritance ×1

super ×1

typing ×1