从1991首次发布,Python语言凭借其易上手易使用等特点迅速吸引了大批开发者,招徕了极高的人气,在编程领域的占有率也因此一直处于稳步上升之中。根据最新的数据,Python排名第七,作为一门还很年轻的语言,Python的位置已经相当令人振奋了。

随着脚本语言的风靡以及诸如Ruby、PHP、Perl等竞争对手的出现,会给Python带来哪些影响;Python正致力于新版本的升级而且将修正其中的历史问题,指的又是什么;新版本的体验如何……带着诸多问题记者采访了使用C++转而使用Python的赖勇浩。

记者:你原来使用的是C++,转到Python的原因是什么?对于Python这门语言的优越性你更有体会,能否谈一下?

赖勇浩:我原来使用了大约四年的C++,转到 Python 首先是因为工作需要——其实是接触 Python 后为其所吸引吧。谈到 Python 的优越性,这是一个见仁见智的问题,一直争论不断。如果非要我说,我觉得它的优越性在于你将拥有更多的时间关注你的业务本身、拥有更的时间陪伴你的家人、拥有更多的时间阅读(或睡觉、交友、运动、旅行等)。

这等于说,使用 Python ,能延长你的生命。为什么这样说呢?因为 Python 支持面向过程、面向对象、函数式编程以及其它编程风格;简洁而极具表达力的语法和丰富而实用的组件都让我们能够事半功倍地完成任务。举个例子,我最近在 Google Code 上创建了一个开源项目——游戏人工智能演示(点击进入链接 ),它完全使用 Python 编写,已经完成了两个简单的 demo 。每一个 demo 都是如此短小,整个框架是如此清晰,舍 Python 而谁能如斯?使用 Python 编程,编程就成为了快乐。

记者:能否谈谈如今Python语言的地位以及它的主要应用面?

赖勇浩:Python 近几年已经进入了最流行的编程语言的前十名,可以说是最成功的脚本语言之一。据我所了解的,Python 最重要的应用面在于 Web 和游戏开发;在国外也有很多企业应用和桌面项目都是使用 Python 开发的,但国内相对就少些。07年8月我在《游戏创造》撰文描述了脚本在游戏业中的现状、优势和前景(点击进入链接 )。Web 方面,随着 Web2.0 势力的进一步扩张,对服务器性能也提出了新的要求,我的老师兼朋友沈崴适时地研制了纯粹基于 Python 的 http 服务器端框架 Eurasia3(点击进入链接 ),preview版本已经到达单进程单线程每秒响应 7000 多个请求的惊人性能,值得关注。

记者:脚本语言的风靡但也出现了诸如Ruby、PHP、Perl等竞争对手,你认为这会给Python带来哪些影响?

赖勇浩:任何一个语言期望独步天下都是不现实的,人无完人,物无完物,竞争对手的存在才是自身进化的动力。同时值得一提的是 Python 社区一直以温和开放著称,事实上 Python 程序员也是 Ruby 最早的支持者,他们也大多有着浓厚的 C++、Perl、PHP 等老牌语言的开发经验。作为典型的务实派,他们关注实现,他们努力将其他语言的优点融合进来使之符合自身的务实哲学。Ruby 的崛起和PHP的日益强大,正好提供了足够多的特性让 Python 学习、进化、和完善自身。

记者:Python目前正致力于核心平台的两次升级,最先出现的版本将是Python 2.6,它将作为Python 3.0公布之前的过渡版本。对于性能方面,目前的alpha版本中尚有哪些不足?

赖勇浩:对于 Python 的升级版,我一直在关注。在 9 月初的时候,我在自己的博客中发表了对 Python 3.0 alpha 1 的试用报告(点击进入链接 ),后经整理、润饰,发表在07年11期的《程序员》杂志上。

毫不掩饰地说,我对 Python 的升级版本是非常期待的。新版本的Python 在一定程度上降低了语言的复杂性,比如现有版本 dict 类的 haskey() 函数就违背了接口一致性并在性能上有所损失。新版本去除了这个成员函数,维护了接口的一致性,也提升了性能。对于现在的 Python 版本,我比较期望的是接纳 wxPython 为默认的 GUI 库。不过现在看来可能性比较小;另外还有一个期望是能够去除 GIL (全局解释器锁),以使程序员能够更容易地获得多核 CPU 的性能优势,但实现的可能性更小。

记者:在版本升级的报道中,“it's come to many people's realizations that there are some problems with the original design”却又没有细说,你认为“original design”指的是哪些?

赖勇浩:Python 是一个成熟的脚本语言,但绝不完美。因为从它的发展历程来看,初期的很多设计都受限于 Guido 的能力,留下了不少缺陷,比如前文提到的 GIL 。幸运的是 Python 社区和 Guido 都非常的开明谦逊,接受了很多意见和建议(详见PEPs:http://www.python.org/dev/peps/),并给出了可行的修改计划。我们可以看到 Python 正在完善自身,如 3.0 版本的变化主要是去除自身的一些特性。去除,这正是完美之道。

谈到带有缺陷的最初设计,2002年Guido 在 OSCON 上名为《Python Regrets》的演讲(点击进入链接 )是我能找到的唯一比较详尽的一份谈论 Python 设计缺陷的资料。从 Py3.0 alpha 1版本来看,新版本做出的修正大体上都对应着这份 PPT 里举出的条目,可见 Guido 果然是直面缺陷,身体力行。【记者:呐不喊】

简介

赖勇浩,现供职于网易广州,致力于高效能编程和游戏人工智能的研究。好编程,好读书,以在博客(http://blog.csdn.net/lanphaday)上与大家分享心得为乐。【CSDN 】

Tags:
Posted on November 27, 2007 6:05 PM | | Comments (0) | TrackBacks (0)

#!/usr/bin/python

def main():
print “Content-type: text/html”
print
print “<html><head>”
print “<title>Hello World from Python</title>”
print “</head><body>”
print “Standard Hello World from a Python CGI Script”
print “</body></html>”

if __name__ == “__main__”:
main()

Tags:
Posted on October 19, 2007 5:40 PM | | Comments (0) | TrackBacks (0)

import sqlobject
from Connection import conn

class PhoneNumber(sqlobject.SQLObject):
_connection = conn
number = sqlobject.StringCol(length=14, unique=True)
owner = sqlobject.StringCol(length=255)
lastCall = sqlobject.DateTimeCol(default=None)
PhoneNumber.createTable(ifNotExists=True)

Tags:
Posted on October 19, 2007 5:39 PM | | Comments (0) | TrackBacks (0)

#!/usr/bin/python
# for linux

import sys

def main():
print “Content-type: text/html\n”
print “<HTML><TITLE>Hello World from Python</TITLE><body>”
print “Standard Hello World from a Python CGI Script<p />”

print “It is very important that Python CGI scripts…”
print “<ol>”
print “<li>have ‘<code>!#usr/bin/python</code>’ ”
print “as the first line of the file<br/>”
print “By default, this will get you Python %s<br/>” % sys.version
print “For specific versions of Python here at Dreamhost…<br/>”
print “v2.1.3 -> <code>#!/usr/bin/python2.1</code><br/>”
print “v2.2.1 -> <code>#!/usr/bin/python2.2</code><br/>”
print “v2.3.5 -> <code>#!/usr/bin/python2.3</code><br/>”
print “</li>”
print “<li>end in ‘<code>.py</code>’</li>”
print “<li>print the ‘<code>Content-type: text/html\\n</code>’ header”
print ” in the first line if you want to view the output</li>”
print “<li>mark the file as executable: ”
print “‘<code>chmod 755 [filename.py]</code>’</li>”
print “</ol>”
print “<hr />”
print “This is a self printing file, full source code follows<br/>”
print ‘Or you could view the source directly ‘
print ‘<a href=”helloworld.txt”>helloworld.txt</a>’
print “<hr />”
f = open(’helloworld.py’)
buff = f.readlines()
print “<pre>”
for line in buff:
# remove trailing newline
line = line.rstrip()
# escape less than/greater thans from &lt; &gt; to &amp;lt; &amp;gt; so they are viewable in html
# side effect: in a web browser it will look like it’s doing nothing ;-)
line = line.replace(”<”,”&lt;”)
line = line.replace(”>”,”&gt;”)
print line
print “</pre>”
print “</body></HTML>”

if( __name__ == “__main__”):
try:
main()
except:
print “Content-type: text/html\n”
print “<HTML>”
print “<title>error?</title>”
print “<body>”
print “There was an error on the page<p/>”
print “Notes:<br/>”
print “&nbsp;exception handling is your friend</br>”
print “&nbsp;cgitb only works with current versions (>=2.3 ?) of Python<br/>”
print “&nbsp;not even an except block can recover from a print ”
print “without a closing quote - you’ll get an error 500 from the server”
print “<body>”
print “</HTML>”

#EndOfFile

Tags:
Posted on October 19, 2007 5:38 PM | | Comments (0) | TrackBacks (0)

#! /usr/bin/python
print “Content-type:text/html\n”
print “\n”
print “Hello, World!”

Tags:
Posted on October 19, 2007 5:38 PM | | Comments (0) | TrackBacks (0)

import sqlobject
from sqlobject.mysql import builder
conn = builder()(user=’root’, passwd=’janlon’,
host=’localhost’, db=’sqlobject_demo’)

Posted on October 19, 2007 5:37 PM | | Comments (0) | TrackBacks (0)

http://www.ActiveState.com

 Komodo IDE 4.2.0 Beta 5

http://www.onlinedown.net/soft/56003.htm

komodo4 ide 破解

http://blog.srzc.com/user1/CrazyQ/archives/2007/4215.html

Posted on October 19, 2007 5:36 PM | | Comments (0) | TrackBacks (0)

问个问题,通过manage.py syncdb后建立表时候,提示是否建立username和password,不知道这个能否修改?在那里修改呢?

在limodou那里找到答案了:
manage.py shell
>>> from django.contrib.auth.create_superuser import createsuperuser
>>> createsuperuser()

“然后运行python manage.py syncdb来安装admin使用的额外的表
注意,在你第一次运行syncdb时,你很可能被问起是否创建一个superuser
如果那时你没有创建superuser,你需要运行djang/contrib/auth/bin/create_superuser.py
来创建一个admin用户,否则你就不能登录到管理界面里去”

Posted on October 19, 2007 5:35 PM | | Comments (0) | TrackBacks (0)

http://www.djangoproject.com/documentation/tutorial01/

http://www.djangoproject.com/documentation/tutorial02/

http://www.djangoproject.com/documentation/tutorial03/

http://www.djangoproject.com/documentation/tutorial04/

Django Step by Step

http://limodou.51boo.com/book/2/

Chapter 5: Interacting with a database: Models

http://www.djangobook.com/en/beta/chapter05/ 今天看了一下,最后部分作者还没有完成,期待中。

Tags:
Posted on October 19, 2007 5:31 PM | | Comments (0) | TrackBacks (0)

from django.template import Template

提示“DJANGO_SETTING_MODULE ”环境变量有问题;

解决方法:

使用指令 python manage.py shell,然后再执行from django.template import Template

Posted on October 19, 2007 5:31 PM | | Comments (0) | TrackBacks (0)
1 2 3 4 5 6 7 下一页
相关内容
广告计划
最新评论
[评论] lym328 : 客源CRM非常不错-----如有需要可以了解
[评论] kevinwu : 作用肯定是有的,Google会首先搜索站
[评论] ss : 其实还真的感觉不到sitemap的作用~
[评论] kevinwu : 谢谢你的关注 :-)
[评论] h51h : 贵博客写得非常的好,界面简洁但内
[评论] snguo : 这里很好 来这里支持下呢?
[评论] redondo : 感谢你分享知识! 这篇文章我转载到
[评论] kevinwu : 就是这本;看来我买的贵了点 - 8折;我
[评论] 安妮 : 《Flex3.0 RIA开发详解:基于ActionScript3.0
[评论] kevinwu : 这个主意不错,有空我整理一下,做