TableOfContents

Python语言介绍

Python是一种解释型的编程语言,由Guido van Rossum于1990年创造。Python是完全动态类型的语言,使用自动的内存管理;在这方面它和Perl、Ruby、Scheme、Smalltalk和Tcl语言是类似的。Python是由开放源代码项目开发,由非盈利性组织Python软件基金会(Python Software Foundation)管理,并在项目网站上免费开放。Python 2.4.3版于2006年3月29日发布。

编程范式:

多范式

出现时间:

1990

设计者:

Guido van Rossum

开发者:

Python Software Foundation

最新版本:

2.4.3 / March 29, 2006

类型规则:

强类型,动态类型(鸭子类型)

主要的实现版本:

CPython, Jython, IronPython, PyPy

受哪些语言影响:

ABC, Modula-3, Icon, C, Perl, Lisp, Smalltalk, Tcl

影响了哪些语言:

Ruby, Boo

操作系统:

跨平台

许可证:

Python Software Foundation License

网站:

www.python.org

1. Python应用领域

Python在很多不同的应用领域都可以使用,包括Web和因特网、数据库、桌面图形界面,科学和数值计算、教育、网络、软件构建和测试、游戏开发、三维渲染等等。

1.1. Web与因特网开发

Python offers a wide range of choices for web development including high-end solutions such as Zope, mega frameworks such as Django and TurboGears, and advanced content management systems such as Plone and CPS. Python is also great for CGI.

Python's extensive support for XML, email, RSS feeds, and many other Internet protocols makes Python a great choice for developing custom web solutions and other internet-based applications.

1.2. 数据库访问

Need to access a database? Custom and ODBC interfaces to MySQL, Oracle, MS SQL Server, PostgreSQL, SybODBC, and others are available for free download.

1.3. 桌面图形界面

Python arrives on your hard drive with the Tk GUI development library. Third-party libraries are available for MFC (via win32 extensions), wxWidgets, GTK, Qt, Delphi, and more. Scientific and Numeric

Python is widely used in scientific and numeric computing, including in Bioinformatics (see also Python course in Bioinformatics) and Physics, among others.

1.4. 教育

Python是一种非常适合程序设计教学的语言,无论是在入门级别还是在更进一步的课程上。Education Special Interest Group是一个好的开端。可以参考pyBiblio和Software Carpentry Course(由Python Software Foundation资助)。

1.5. 网络编程

In addition to web and internet support described above, Python also provides support for lower level network programming with its easy to use sockets implementation and with powerful third party modules such as Twisted, a framework for asyncronous network programming,

1.6. 软件开发

Python is often used as a support language for software developers, for build control and management, testing, and in many other ways. Some of the development support tools written in Python include SCons for build control, Buildbot and Apache Gump for automated continuous compilation and testing, and Trac for bug tracking and project management.

See also the list of Integrated Development Environments available for Python and the Python Package Index, which hosts thousands of third party modules for Python.

1.7. 游戏和三维图形

Python is widely used in commercial and hobby game development (some of which are listed on the Python Games wiki page). PyGame and PyKyra are two of the game frameworks available for Python. There are also a number of 3D rendering libraries available for Python.

2. Python应用实例

The Python programming language is actively used in industry and academia for a wide variety of purposes.

2.1. Python的教育用途

As of 2005, Python is getting more popular for teaching computer programming. Its strengths for teaching include its syntactic simplicity, flexible typing, and interactive interpreter.

Python uses far fewer symbols than languages like Java and C. For example blocks inside loops and IF statements are indicated by indentation rather than curly braces ({}), and the end of a line does not have to have a semicolon. Beginning students often have initial trouble with memorizing where curly braces and semi-colons go. With Python students can skip directly to the fun part of writing code that does something. Similarly, with Java, and C++, variables types must be declared before being used. That is not needed in Python which again allows students to quickly get to the interesting part of getting their program to do something.

The interactive interpreter is an extremely valuable aid to learning and experimentation. Learning-by-doing is about trying things out and seeing what happens. The faster you can get results from your experiment, the faster that learning produces results. Experience has shown that the interactive interpreter and lack of a compiler really speeds up the learning process, both for beginners and for pros who are learning a new library and such.

2.2. 使用Python的大型组织

2.3. 使用Python写成的软件

2.4. Python包

The Python Cheese Shop and Vaults of Parnassus are two primary directories of hundreds of Python packages

See more recommended modules at Useful Modules in the Python.org wiki.

2.5. Python软件目录

3. Python的实现

The standard Python interpreter also supports an interactive mode in which it acts as a kind of shell: expressions can be entered one at a time, and the result of their evaluation is seen immediately. This is a boon for those learning the language and experienced developers alike: snippets of code can be tested in interactive mode before integrating them into a proper program. As well, the Python shell is often used to interactively perform system tasks, such as modifying files.

Python also includes a unit testing framework for creating exhaustive test suites. While static typing aficionados see this as a replacement for a static type-checking system, Python programmers largely do not share this view.

Standard Python does not support continuations, and according to Guido van Rossum, never will. However, better support for coroutine-like functionality is planned, by extending Python's generators [3]

4. Python的标准库

Python有一个巨大的标准库,这使得Python适合于完成很多任务。Python模块的哲学被称作"内置电池"。标准库中的模块可以通过C语言或者Python语言写成的模块来增加。标准库被精心的设计用以编写面向Internet的应用,包括对大量的标准格式和协议的支持(比如MIME和HTTP)。同时也包括编写图形用户界面的模块,连接关系型数据库的模块,任意精度的算术运算模块,以及处理正则表达式的模块。

标准库是Python的一个强大之处。其中大部分是跨平台的,这意味着即使是横跨多个领域的Python程序也可以不经过修改直接运行在Unix、Windows、Macintosh以及其他平台上。

现在正在争论第三方的开源模块比如Twisted、NumPy、wxPython等是否应该被包括在标准库之中,以使其跟内置电池的哲学一致。

ch3n2k.com | Copyright (c) 2004-2020 czk.