前段时间在讲述 Flask-Login 的源码中遇见了一个函数 ——partial,这个函数来自于functools模块,这个模块定义为”The functools module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a function for the purposes of this module”,翻译成中文的大概意思就是”functools 用于高阶函数:指那些作用于函数或者返回其他函数的函数。总的来说,这个模块的目标就是将任何可调用的对象都可以被视为函数。”
classint(object) | int(x=0) -> integer | int(x, base=10) -> integer | | Convert a number or string to an integer, orreturn 0 if no arguments | are given. If x is a number, return x.__int__(). For floating point | numbers, this truncates towards zero. | | If x isnot a number orif base is given, then x must be a string, | bytes, orbytearray instance representing an integer literal in the | given base. The literal can be preceded by '+' or '-' and be surrounded | by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. | Base 0 means to interpret the base from the string as an integer literal. | >>> int('0b100', base=0) | 4