Welcome to 陈俊峰's ---BeetleHeaded Man Blog !

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  58 随笔 :: 32 文章 :: 18 评论 :: 0 Trackbacks
Python读书笔记( 2006-4-12 ):

Note One   : about integer and long integer
There are four types of numeric literals: plain integers, long integers, floating point numbers, and imaginary numbers. There are no complex literals (complex numbers can be formed by adding a real number and an imaginary number).
Note that numeric literals do not include a sign; a phrase like -1 is actually an expression composed of the unary operator `-' and the literal 1

Note Two   : about operators
The comparison operators <> and != are alternate spellings of the same operator. != is the preferred spelling; <> is obsolescent.

Note Three: about delimiters
The following printing ASCII characters are not used in Python. Their occurrence outside string literals and comments is an unconditional error:   $       ?

Note Four  : about Sequences
Sequences also support slicing: a[i:j] selects all items with index k such that  i <= k < j  When used as an expression, a slice is a sequence of the same type. This implies that the index set is renumbered so that it starts at 0. Some sequences also support ``extended slicing'' with a third ``step'' parameter: a[i:j:k] selects all items of a with index x where  x = i +n*k , n >= 0  and i <= x < j.


Note Five   : about Primary Prompt
In interactive mode, the last printed expression is assigned to the variable _. This means that when you are using Python as a desk calculator, it is somewhat easier to continue calculations, for example:

>>> tax = 12.5 / 100
>>> price = 100.50
>>> price * tax
12.5625
>>> price + _
113.0625
>>> round(_, 2)
113.06
>>>

This variable should be treated as read-only by the user. Don't explicitly assign a value to it -- you would create an independent local variable with the same name masking the built-in variable with its magic behavior.
posted on 2006-04-12 19:00 Jeff-Chen 阅读(162) 评论(0)  编辑 收藏 引用 所属分类: Python

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理