如果妳祈求心灵的平和与快乐,就去信仰上帝!如果妳希望成为一个真理的门徒,探索吧!! -- 尼采
I can calculate the motions of havenly bodies, but not the madness of people. -- Newton
You have to be out to be in.

搜索引擎

Java, Web, Searching Engine

  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  24 随笔 :: 25 文章 :: 27 评论 :: 0 Trackbacks

Variables and Expression


The object to which a reference is bound at a given time always has a type, but a given reference may be bound to objects of various types during the program's execution.


Variables

In Python there are no declarations.

The existence of a variable begins with a statement that binds the variable. You can also unbind a variable, resetting the name so it no longer holds a reference. The del statement unbinds references.

Rebinding or unbinding a reference has no effect on the object to which the reference was bound, except that an object disappears when nothing refers to it.

The automatic cleanup of objects bereft of references is known as garbage collection.

A global variable is an attribute of a module object. A local variable lives in a function's local namespace.

Object attributes and items

An attribute of an object is denoted by a reference to the object, followed by a period (.). Attributes that are callable are also known as methods.
An item of an object is denoted by a reference to the object, followed by an expression within brackets ([]).

Python draws no strong distinction between callable and noncallable objects, as some other languages do

Special expresion in Python

'expr,...'              String conversion
x is y, x is not y      Identity tests
x in y, x not in y      Membership tests
not x                   Boolean NOT
x and y                 Boolean AND
x or y                  Boolean OR
lambda arg,...: expr    Anonymous simple function

posted on 2007-11-23 23:51 专心练剑 阅读(167) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。