コード例 #1
0
ファイル: bulkfood_v4c.py プロジェクト: ZoroOP/C-and-CPP
class LineItem:
    weight = model.Quantity()  # <2>
    price = model.Quantity()

    def __init__(self, description, weight, price):
        self.description = description
        self.weight = weight
        self.price = price

    def subtotal(self):
        return self.weight * self.price
コード例 #2
0
class LineItem:
    # 这里的方式非常像模型定义,Django中模型的字段就是描述符
    weight = model.Quantity()
    price = model.Quantity()

    def __init__(self, description, weight, price):
        self.description = description
        self.weight = weight
        self.price = price

    def subtotal(self):
        return self.weight * self.price