python笔记之编程风格大比拼 虽然我的python age并不高,但我仍然愿意将我遇到的或者我写的有趣的python程序和大家一块分享,下面是我找到的一篇关于各类python程序员的编程风格的比较文章,以阶乘为例,很有意思。 新手程序员 def factorial(x): if x == 0 : return 1 else : return x * factorial(x - 1 ) print factorial( 6 ) 第一年的刚学完Pascal的新手 def factorial(x): result = 1 i = 2 while i <= x: result = result * i i = i + 1 return result print factorial( 6 ) 第一年的刚学完C语言的新手 def fact(x): #{ result = i = 1 ; while (i <= x): #{ result *= i ; i += 1 ; #} return result ; #} print (fact( 6 )) 第一年刚学完SICP的新手 @tailcall def fact(x, acc = 1 ): if (x > 1 ): return (fact((x - 1 ), (acc * x))) else : return acc print