-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Description
位置:
- 8.13小节 使用类装饰器案例
- pdf 270 页
当前原文:
# 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- 此处装饰器中
share和price字段未示例化,类型为<class 'type'>。 - 此处应该实例化为
<class '__main__.UnsignedInteger'>,即:shares=UnsignedInteger(), price=UnsignedFloat()
改正后内容:
# 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望解答指正~
Metadata
Metadata
Assignees
Labels
No labels