
FluentPython
luo_xinyu
这个作者很懒,什么都没留下…
展开
-
FluentPython读书笔记3 --2-8.1
# -*- coding:utf-8 -*-import bisectimport sysHAYSTACK = [1, 4, 5, 6, 8, 12, 15, 20, 21, 23, 23, 26, 29,30]NEEDLES = [0, 1, 2, 5, 8, 10, 22, 23, 29, 30, 31]ROW_FMT = '{0:2d} @ {1:2d} {2}{1:&l...原创 2018-12-22 22:02:38 · 247 阅读 · 0 评论 -
FluentPython读书笔记1--1.1
import collectionsfrom random import choice# AAAAAAAA(rank='spades', suit='2') 出来的名字是括号里的‘Card’Card = collections.namedtuple('Card', ['rank', 'suit'])t_card = Card('7', 'hearts')print t_cardran...原创 2018-12-10 21:51:30 · 185 阅读 · 0 评论 -
FluentPython读书笔记2 --1.1.2
from math import hypotclass Vector: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): x = self.x + other.x y = self.y + other.y ...原创 2018-12-13 09:19:52 · 162 阅读 · 0 评论 -
python装饰器的两个应用,参数检查,输出进度条
一、参数检查from functools import wrapsfrom typing import Listdef ckeck_params(func): @wraps(func) def inner(*args, **kwargs): params = func.__annotations__ print('params: ', pa...原创 2019-04-18 20:03:24 · 917 阅读 · 0 评论