ladbrokes.com

Tag Archives: decorator

Constraints on Arguments in Python

When Dynamic Type comes to Trouble As a dynamic programming languages , Python don't have a type on variables , as well as a arguments . This feature save us a lot workload and it enable us to focus on logical of program . def add(x, y): return x+y print add(5,6) >> 11 print add("D","E") >> "DE" print add(5.0, 6) >> 11.0 Above function is straightforward and works fine if x and y are passed with int/ float/ string . But things may Read more [...]

[译文]Decorators and Functional Python[draft]

Original blog post wrote by Brian Holdefehr. This is a Chinese version of original post . 本文原文作者 Brian Holdefehr。若有不足,敬请斧正。 装饰器(Decorators) 是Python众多强大特性之一。装饰器除了本身编程语法上的作用之外,另外提供了一种有趣思维方式——"函数化"思维(a functional way) 我会从头开始介绍介绍装饰器的工作原理,接着会介绍几个必须了解的基本概念。之后,我们会详细深入探索一些装饰器实例以及其工作方式。最后我们会讨论一些装饰器的高阶应用,例如参数化装饰器(optional Read more [...]