money.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:CommunityCellularManager 作者: facebookincubator 项目源码 文件源码
def __init__(self, amount=None, currency=DEFAULT_CURRENCY,
            amount_raw=None):
        if not (amount is None) ^ (amount_raw is None):
            raise ValueError("You must specify an amount or a raw amount")

        if not isinstance(currency, Currency):
            raise TypeError("You must specify a valid Currency")

        if amount is not None:
            if not isinstance(amount, numbers.Real):
                raise TypeError("Amount must be an integer or float")
            amount_raw = int(amount * 10**currency.precision)

        if not isinstance(amount_raw, numbers.Integral):
            raise TypeError("Amount must be an integer or float")

        self.amount_raw = amount_raw
        self.currency = currency
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号