详细情况请看这里: http://python.org/download/releases/3.0/
原文看这里 http://www.artima.com/weblogs/viewpost.jsp?thread=211200 Guido van Rossum 大叔挺顽固的,哈哈。 文中他表达了极度不爽FP,直接就说 I hate functional programming,还说 Don't use these with a lambda though; then a list comprehension is clearer and faster。 reduce 他老人家已经准备给 去掉了,说是reduce 使代码极不可读。唉那天如果大叔一个不爽 把lambda , 之类的给删了,那就 ...
http://www.artima.com/weblogs/viewpost.jsp?thread=208549 引用For a long time there wasn't much more than a list of regrets and flaws that were impossible to fix without breaking backwards compatibility. The idea was that Python 3000 would be the first Python release to give up backwards compatibi ...
请看这段程序 a = 0 b = 0 while a is b: a += 1 b += 1 print id(a), a print id(b), b 猜猜结果,呵呵结果是 13013836 257 13013812 257 原因在这里: 引用This is really hardcoded limit in the current CPython implementation :) The interpreter preallocates numbers from 0 to 256. 大家可以看下intobject.c的有关这部分的源码: #if ...
地址在下面,都是些有趣的数学题,有兴趣的可以去玩玩. http://www.projecteuler.net 呵呵我刚做完前10题,以后每做完10题都会发到我博客上。 PS:我用的是python和c写的。 1 引用 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. d ...
May 31 is Google Developer Day       Guido Van Rossum, Google software engineer and creator of the Python programming language (Beijing);    [quote]   http://googleblog.bl​ogspot.com/2007/04/m​ay-31-is-google-deve​loper-day.html   http://www.google.co​m/events/developerda​y/zh_CN/details.html[/q ...
http://www.python.org/download/releases/2.5.1/ 看了下介绍,是修正了一些bug, 其他的没什么改变,呵呵我还以为3.0要快放出来了呢. 引用This is the first bugfix release of Python 2.5. Python 2.5 is now in bugfix-only mode; no new features are being added. According to the release notes, over 150 bugs and patches have been squished since Py ...
文章在这里: http://www.norvig.com/spell-correct.html import re, string, collections def words(text): return re.findall('[a-z]+', text.lower()) def train(features): model = collections.defaultdict(lambda: 1) for f in features: model[f] += 1 return model NWORDS = train(wor ...
判断一个数是否为质数的方法: import re def is_prime(num): return not re.match(r"^1?$|^(11+?)\1+$", '1' * num) 在这里转一下一个对这段代码评论 http://blog.csdn.net/g9yuayon/archive/2007/03/19/1533798.aspx 引用 这段代码除了漂亮精巧值得欣赏,以及可以用来玩味理解regex以外,还有什么价值呢?效率?显然不够高。实用性?恐怕也没有多少。不过,这段代码隐含了重要的编程思想:编码。我们可以把一段问题用某种方式表达出来,再根据这段表达谋 ...
http://chn.blogbeta.com/232.html 讲的很是不错,把FP讲的很生动,很清晰.
  参考 python in nutshell 的第三版. 1.在python中异常被认为无论什么时候只要能使程序更简单更强大就可以被使用。甚至异常可以被频繁的抛出. 2.在很多语言中,他们所遵从的是"look before you leap" (LBYL),也就是说,在尝试一个操作之前首先应该先检查一下.这里我的理解就是LBYL只是关心语法而不是关心语义的表达。可是python中遵从的是"it's easier to ask forgiveness than permission"既(EAFP),这也是cobol所遵从的,呵呵我在这里的理解是什么都不管先做再说。EAFP更注重 ...
__slots__保存着实例变量的列表,并且在实例中保留空间以确定它们在实例中。一旦使用了__slots__,其它的实例变量就不能被赋值了。 文档中是这么说的: 引用 This class variable can be assigned a string, iterable, or sequence of strings with variable names used by instances. If defined in a new-style class, __slots__ reserves space for the declared variables and prevents ...
今天看 python in nutshell 时看到了这段 Reader who are familiar Lisp, Scheme, or functional-programming languages must in particular be aware that Python does not implement the optimization of "tail-call elimination," which is so important in these languages. In Python, any call, recursive or not, has the sa ...
本以为已经挂了,今天无意中去逛了一下,竟然更新了,而且看了它的roadmap对以后还是挺期待的 http://www.jython.org/Project/roadmap.html 这次的更新有 : 引用 Jython 2.2 beta1 New features - much improved support for __unicode__ especially in the parser (u"string" and friends now result in a PyUnicode object) - added datetime suppo ...
在windows下 width = input('Please enter width: ') 这条语句 为什么我在 IDLE下运行就是 正确的 而在pydev+eclipse 下,一运行然后输入 数字 打个回车就会出错呢? 只能用raw_input来代替. 错误显示 SyntaxError: unexpected EOF while parsing 文档中 This function is not safe from user errors! It expects a valid Python expression as input; if the input is not s ...
simohayha
搜索本博客
存档
最新评论