yidao620c / python3-cookbook

《Python Cookbook》 3rd Edition Translation
11.7k stars 2.97k forks source link

8.13小节 使用类装饰器案例未实例化 #375

Open abookworm opened 2 months ago

abookworm commented 2 months ago

位置:

当前原文:

# Example
@check_attributes(name=SizedString(size=8),
                  shares=UnsignedInteger,
                  price=UnsignedFloat)
class Stock:
    def __init__(self, name, shares, price):
        self.name = name
        self.shares = shares
        self.price = price

改正后内容:

# Example
@check_attributes(name=SizedString(size=8),
                  shares=UnsignedInteger(),
                  price=UnsignedFloat())
class Stock:
    def __init__(self, name, shares, price):
        self.name = name
        self.shares = shares
        self.price = price

望解答指正~