青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

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

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  58 隨筆 :: 32 文章 :: 18 評論 :: 0 Trackbacks
Note One : Lists Comprehensions
[3*x for x in vec if x > 3]
[x*y for x in vec1 for y in vec2]
......
there expression can used to instead the functional programming tools such as map() ,filter(),reduce()..

Note Two : Some functions in the modules often? be made used of
1.strip()
?:? Return a copy of the string s with leading and trailing?whitespace removed.
>>> test_str = '?? I Love Python? '
>>>?string.strip(test_str)
'I Love Pyhon'??? Note that : whitespace at the two side of the string were removed ,but it did not worked on the whitespace between string!
2. str() : can convert the format like int ,long , float ... into string format
>>> num_1 = 3.14
>>> num_2 = 0.618
>>> str(num_1) , str(num_2)
'3.14' '0.618'
3.dict()
dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object's
??? (key, value) pairs.
dict(seq) -> new dictionary initialized as if via:
??? d = {}
??? for k, v in seq:
??????? d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
??? in the keyword argument list.? For example:? dict(one=1, two=2)

e.g?
dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
dict([(x, x**2) for x in (2, 4, 6)])????
dict(sape=4139, guido=4127, jack=4098)

4. enumerate()
Return an enumerate object.? iterable must be an other object that supports
iteration.? The enumerate object yields pairs containing a count (from
zero) and a value yielded by the iterable argument.? enumerate is useful
for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
Code? show:
>>> for i, v in enumerate(['tic', 'tac', 'toe']):
...???? print i, v
...
0 tic
1 tac
2 toe

5 zip()
Return an enumerate object.? iterable must be an other object that supports
iteration.? The enumerate object yields pairs containing a count (from
zero) and a value yielded by the iterable argument.? enumerate is useful
for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
Code Show:

>>> questions = ['name', 'quest', 'favorite color']
>>> answers = ['lancelot', 'the holy grail', 'blue']
>>> for q, a in zip(questions, answers):
...     print 'What is your %s?  It is %s.' % (q, a)
...	
What is your name?  It is lancelot.
What is your quest?  It is the holy grail.
What is your favorite color?  It is blue.

6.sorted()
Code Show:
>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> for f in sorted(set(basket)):
...     print f
... 	
apple
banana
orange
pear

to be continued......

Note Three : simple statements

7 The yield statement
Download entire grammar as text.

The yield statement is only used when defining a generator function, and is only used in the body of the generator function. Using a yield statement in a function definition is sufficient to cause that definition to create a generator function instead of a normal function.

When a generator function is called, it returns an iterator known as a generator iterator, or more commonly, a generator. The body of the generator function is executed by calling the generator's next() method repeatedly until it raises an exception.

When a yield statement is executed, the state of the generator is frozen and the value of expression_list is returned to next()'s caller. By ``frozen'' we mean that all local state is retained, including the current bindings of local variables, the instruction pointer, and the internal evaluation stack: enough information is saved so that the next time next() is invoked, the function can proceed exactly as if the yield statement were just another external call.

The yield statement is not allowed in the try clause of a try ... finally construct. The difficulty is that there's no guarantee the generator will ever be resumed, hence no guarantee that the finally block will ever get executed.

Note: In Python 2.2, the yield statement is only allowed when the generators feature has been enabled. It will always be enabled in Python 2.3. This __future__ import statement can be used to enable the feature:

from __future__ import generators

8 The raise statement

raise_stmt::="raise" [expression ["," expression ["," expression]]]
Download entire grammar as text.

If no expressions are present, raise re-raises the last exception that was active in the current scope. If no exception is active in the current scope, a TypeError exception is raised indicating that this is an error (if running under IDLE, a Queue.Empty exception is raised instead).

Otherwise, raise evaluates the expressions to get three objects, using None as the value of omitted expressions. The first two objects are used to determine the type and value of the exception.

If the first object is an instance, the type of the exception is the class of the instance, the instance itself is the value, and the second object must be None.

If the first object is a class, it becomes the type of the exception. The second object is used to determine the exception value: If it is an instance of the class, the instance becomes the exception value. If the second object is a tuple, it is used as the argument list for the class constructor; if it is None, an empty argument list is used, and any other object is treated as a single argument to the constructor. The instance so created by calling the constructor is used as the exception value.

If a third object is present and not None, it must be a traceback object (see section?3.2), and it is substituted instead of the current location as the place where the exception occurred. If the third object is present and not a traceback object or None, a TypeError exception is raised. The three-expression form of raise is useful to re-raise an exception transparently in an except clause, but raise with no expressions should be preferred if the exception to be re-raised was the most recently active exception in the current scope.

Note Four : Compound Statements

9 The try statement

The try statement specifies exception handlers and/or cleanup code for a group of statements:

try_stmt::=try_exc_stmt | try_fin_stmt
try_exc_stmt::="try" ":" suite
("except" [expression ["," target]] ":" suite)+
["else" ":" suite]
try_fin_stmt::="try" ":" suite "finally" ":" suite
Download entire grammar as text.

There are two forms of try statement: try...except and try...finally. These forms cannot be mixed (but they can be nested in each other).

The try...except form specifies one or more exception handlers (the except clauses). When no exception occurs in the try clause, no exception handler is executed. When an exception occurs in the try suite, a search for an exception handler is started. This search inspects the except clauses in turn until one is found that matches the exception. An expression-less except clause, if present, must be last; it matches any exception. For an except clause with an expression, that expression is evaluated, and the clause matches the exception if the resulting object is ``compatible'' with the exception. An object is compatible with an exception if it is either the object that identifies the exception, or (for exceptions that are classes) it is a base class of the exception, or it is a tuple containing an item that is compatible with the exception. Note that the object identities must match, i.e. it must be the same object, not just an object with the same value.

If no except clause matches the exception, the search for an exception handler continues in the surrounding code and on the invocation stack.

If the evaluation of an expression in the header of an except clause raises an exception, the original search for a handler is canceled and a search starts for the new exception in the surrounding code and on the call stack (it is treated as if the entire try statement raised the exception).

When a matching except clause is found, the exception's parameter is assigned to the target specified in that except clause, if present, and the except clause's suite is executed. All except clauses must have an executable block. When the end of this block is reached, execution continues normally after the entire try statement. (This means that if two nested handlers exist for the same exception, and the exception occurs in the try clause of the inner handler, the outer handler will not handle the exception.)

Before an except clause's suite is executed, details about the exception are assigned to three variables in the sys module: sys.exc_type receives the object identifying the exception; sys.exc_value receives the exception's parameter; sys.exc_traceback receives a traceback object (see section?3.2) identifying the point in the program where the exception occurred. These details are also available through the sys.exc_info() function, which returns a tuple (exc_type, exc_value, exc_traceback). Use of the corresponding variables is deprecated in favor of this function, since their use is unsafe in a threaded program. As of Python 1.5, the variables are restored to their previous values (before the call) when returning from a function that handled an exception.

The optional else clause is executed if and when control flows off the end of the try clause.7.1 Exceptions in the else clause are not handled by the preceding except clauses.

The try...finally form specifies a `cleanup' handler. The try clause is executed. When no exception occurs, the finally clause is executed. When an exception occurs in the try clause, the exception is temporarily saved, the finally clause is executed, and then the saved exception is re-raised. If the finally clause raises another exception or executes a return or break statement, the saved exception is lost. A continue statement is illegal in the finally clause. (The reason is a problem with the current implementation - this restriction may be lifted in the future). The exception information is not available to the program during execution of the finally clause.

When a return, break or continue statement is executed in the try suite of a try...finally statement, the finally clause is also executed `on the way out.' A continue statement is illegal in the finally clause. (The reason is a problem with the current implementation -- this restriction may be lifted in the future).

posted on 2006-04-15 13:13 Jeff-Chen 閱讀(426) 評論(0)  編輯 收藏 引用 所屬分類: Python
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲国产精品嫩草影院| 亚洲精品国产精品久久清纯直播| 亚洲午夜精品国产| 亚洲精品在线观| 欧美天天影院| 欧美一区二区三区四区在线| 日韩一级视频免费观看在线| 欧美视频一区二区三区| 欧美一级播放| 久久一区国产| 亚洲狼人综合| 亚洲综合大片69999| 国产精品人人做人人爽| 久久综合九色综合欧美就去吻| 久久精品人人做人人爽| 亚洲黄色高清| 中日韩高清电影网| 国精产品99永久一区一区| 免费不卡中文字幕视频| 欧美伦理影院| 久久精品视频免费| 免费在线观看精品| 亚洲欧美日韩国产一区| 欧美中文字幕在线观看| 日韩一级大片在线| 性欧美1819性猛交| 亚洲精品国产精品国自产观看浪潮| 日韩天堂av| 激情综合色综合久久| 亚洲精品视频免费观看| 国产亚洲精品久久飘花| 亚洲国产成人精品久久| 国产精品免费一区二区三区观看| 久久久久久久波多野高潮日日| 免费欧美电影| 欧美在线视频免费| 欧美劲爆第一页| 久久精品欧美日韩| 欧美日韩一区二区三区视频| 欧美综合国产精品久久丁香| 欧美久久电影| 美女91精品| 国产偷国产偷精品高清尤物| 亚洲精品日本| 最近中文字幕日韩精品 | 亚洲第一视频网站| 国产日产亚洲精品| 一区二区三区日韩精品视频| 在线精品国产欧美| 欧美一区亚洲| 欧美在线视频一区二区| 欧美日韩另类字幕中文| 亚洲福利久久| 亚洲国产91| 久久精品国产一区二区三| 亚洲欧美一区二区原创| 欧美日本国产视频| 亚洲精品男同| 亚洲精品日日夜夜| 免费亚洲电影| 欧美国产日韩一区二区| 国内精品免费午夜毛片| 性欧美长视频| 久久久久久久久岛国免费| 国产精品亚洲美女av网站| 亚洲私人影院在线观看| 亚洲婷婷在线| 国产精品扒开腿做爽爽爽软件| 亚洲激情在线播放| 日韩视频久久| 欧美婷婷久久| 亚洲图片激情小说| 欧美在线你懂的| 国产专区综合网| 久久久久久九九九九| 久久久久久久久久久久久久一区| 国产亚洲一二三区| 欧美在线亚洲| 欧美高清你懂得| 日韩一级免费观看| 国产精品久久二区| 欧美亚洲视频在线观看| 麻豆成人综合网| 亚洲精品视频一区| 欧美日韩伊人| 欧美一区二区三区电影在线观看| 久久九九电影| 亚洲人成人一区二区在线观看| 欧美成人资源| 亚洲视频精选| 美腿丝袜亚洲色图| 在线亚洲激情| 国语自产偷拍精品视频偷| 久久久成人精品| 亚洲三级影片| 欧美一区国产在线| 亚洲福利在线看| 欧美日韩中文字幕综合视频| 亚洲免费在线电影| 欧美va亚洲va香蕉在线| 在线亚洲观看| 怡红院精品视频| 国产精品豆花视频| 久久精品青青大伊人av| 亚洲理论在线| 久久午夜国产精品| 中文一区在线| 亚洲风情亚aⅴ在线发布| 欧美日韩国产欧美日美国产精品| 亚洲在线一区二区| 欧美激情亚洲精品| 欧美亚洲一区二区在线观看| 亚洲国产日韩欧美在线图片| 国产精品国产三级国产aⅴ无密码| 久久精品网址| 在线一区观看| 亚洲人成网站精品片在线观看| 久久久xxx| 亚洲性夜色噜噜噜7777| 影音先锋日韩资源| 国产欧美日韩精品专区| 欧美激情一区二区三区蜜桃视频| 欧美亚洲一级| 亚洲一区二区欧美| 亚洲精品小视频| 免费视频亚洲| 久久精品免费| 久久福利视频导航| 亚洲欧美日韩精品久久久久| 亚洲国产清纯| 亚洲第一免费播放区| 国产精品视频内| 欧美日韩一级片在线观看| 美女视频一区免费观看| 久久精品卡一| 久久国产精品第一页| 亚洲伊人观看| 亚洲影视九九影院在线观看| 亚洲精品一级| 亚洲精品美女在线| 最新国产成人在线观看| 欧美国产成人在线| 欧美国产专区| 亚洲高清网站| 亚洲精品欧美日韩| 日韩亚洲不卡在线| 日韩一级大片在线| 99ri日韩精品视频| 中文欧美字幕免费| 亚洲午夜未删减在线观看| 在线视频欧美日韩| 亚洲欧洲av一区二区| 亚洲欧美日韩国产一区| 亚洲欧美在线aaa| 欧美一区二区三区在线观看视频 | 亚洲国内在线| 亚洲欧洲一区二区三区久久| 欧美激情亚洲自拍| 亚洲激情图片小说视频| 亚洲精品乱码久久久久久| 日韩小视频在线观看专区| 亚洲最新中文字幕| 性高湖久久久久久久久| 欧美一级黄色网| 久久最新视频| 欧美精品一卡| 国产精品一区一区三区| 国产自产女人91一区在线观看| 在线观看一区视频| 日韩视频免费在线| 亚洲欧美日韩中文在线制服| 午夜精品国产更新| 欧美不卡视频一区| 一区电影在线观看| 久久精品欧洲| 欧美日韩一区二区在线| 国产精品视频免费一区| 伊人久久男人天堂| 亚洲一区二区精品| 免费短视频成人日韩| 日韩一区二区福利| 久久精品国产99| 欧美精品一区二区三区四区| 国产精品成人观看视频免费| 黄色精品一区二区| 一区二区三区 在线观看视频| 久久国产精品久久久久久| 欧美第十八页| 亚洲综合色自拍一区| 欧美成人黑人xx视频免费观看| 国产精品捆绑调教| 亚洲人成在线影院| 久久国产精品99久久久久久老狼 | 久久亚洲一区二区| 99ri日韩精品视频| 蜜桃精品久久久久久久免费影院| 国产精品v亚洲精品v日韩精品| 1024亚洲| 久久精品日韩欧美| 在线视频欧美日韩|