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

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

  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  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 閱讀(421) 評論(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>
            免费久久99精品国产自| 极品av少妇一区二区| 亚洲性视频网站| 亚洲一区二区三区精品在线观看 | 国产一区二区三区精品欧美日韩一区二区三区 | 欧美wwwwww| 欧美久久一区| 国产精品久久久久久久久久尿 | 亚洲人线精品午夜| 国产精品永久免费| 国产精品免费在线| 一区二区三区在线看| 亚洲精品乱码久久久久久按摩观| 999在线观看精品免费不卡网站| 亚洲视频中文| 毛片基地黄久久久久久天堂| 亚洲欧洲日本mm| 一区二区三区久久网| 欧美在线亚洲| 欧美激情在线免费观看| 国产精品色网| 亚洲精品视频在线观看网站| 欧美一区二区三区播放老司机| 欧美成人免费在线视频| 亚洲女人av| 欧美精品成人一区二区在线观看| 国产精品视频免费观看| 亚洲精品日韩一| 久久久一区二区三区| 亚洲精品午夜| 久久亚洲国产成人| 国产精品视频专区| 日韩网站在线观看| 欧美成人在线免费观看| 亚洲欧美国产精品va在线观看| 欧美韩日一区二区| 在线精品视频一区二区| 校园春色综合网| 亚洲欧洲另类国产综合| 久久久亚洲影院你懂的| 国产欧美日韩一区二区三区在线 | 亚洲一区二区在线免费观看| 老司机亚洲精品| 亚洲欧美日韩国产一区二区三区 | 亚洲国产小视频在线观看| 欧美亚洲一区二区在线观看| 欧美精品一区二区三| 亚洲精品乱码久久久久久日本蜜臀| 久久九九国产| 亚洲欧美日韩综合国产aⅴ| 欧美日韩一区三区四区| 亚洲精品国产精品乱码不99按摩| 老司机一区二区| 久久久欧美一区二区| 国内偷自视频区视频综合| 欧美一区二区三区的| 亚洲午夜激情在线| 国产精品午夜国产小视频| 午夜精品一区二区三区在线视 | 欧美激情亚洲综合一区| 亚洲午夜久久久久久尤物| 欧美人成在线| 中文av一区二区| 一区二区三区高清在线| 欧美日韩精品免费看| 99re视频这里只有精品| 亚洲高清资源| 欧美国产日韩精品免费观看| 亚洲国产国产亚洲一二三| 欧美国产日本| 欧美日韩国产综合视频在线观看中文 | 亚洲久久成人| 欧美电影在线播放| 欧美1区视频| 日韩五码在线| 一本色道久久综合亚洲精品不卡| 国产精品r级在线| 亚洲欧美一区二区视频| 欧美一区二区黄| 影音先锋欧美精品| 亚洲国产一区二区三区a毛片| 欧美日韩精品在线播放| 亚洲欧美三级伦理| 久久精品欧美| 日韩天堂在线视频| 亚洲一区欧美二区| 激情欧美一区二区三区| 亚洲一区二区三区免费在线观看 | 久久精品国产亚洲a| 黄色成人免费观看| 欧美大片在线观看一区二区| 欧美日韩黄色一区二区| 久久精品在线免费观看| 鲁大师影院一区二区三区| 9i看片成人免费高清| 亚洲无线一线二线三线区别av| 国产一区二区欧美| 亚洲精品少妇30p| 国产一区二区三区在线观看免费| 欧美大片免费| 国产亚洲成人一区| 亚洲另类春色国产| …久久精品99久久香蕉国产| 在线一区二区三区做爰视频网站 | 欧美人在线观看| 99re6这里只有精品视频在线观看| 99爱精品视频| 亚洲人成高清| 亚洲女同性videos| 亚洲经典一区| 久久精品亚洲乱码伦伦中文| 亚洲视频一区在线观看| 久久久久久97三级| 午夜视频在线观看一区| 欧美精品xxxxbbbb| 欧美激情视频在线播放| 国模私拍一区二区三区| 亚洲一区二区免费| 亚洲一区二区三区色| 欧美激情bt| 六月婷婷一区| 欧美阿v一级看视频| 亚洲一区日韩| 亚洲一区三区视频在线观看 | 午夜久久tv| 这里只有精品丝袜| 欧美成人免费在线| 六月丁香综合| 在线观看成人av电影| 欧美在线啊v一区| 欧美一区日韩一区| 国产精品免费在线| 亚洲欧美日韩国产中文| 欧美一区在线看| 国产精品久久久一区麻豆最新章节| 亚洲精品五月天| 午夜精品久久久久久久久久久| 午夜精品福利视频| 一本色道久久99精品综合| 一本大道久久a久久综合婷婷| 99成人在线| 亚洲欧洲偷拍精品| 亚洲精品欧美精品| 亚洲日本一区二区| 伊人影院久久| 亚洲国产一区在线观看| 亚洲激情社区| 亚洲午夜久久久久久久久电影院 | aaa亚洲精品一二三区| 亚洲欧美一区二区精品久久久| 亚洲乱码国产乱码精品精天堂 | 亚洲三级性片| 欧美日韩中文字幕综合视频| 亚洲视频每日更新| 欧美一区二区精品久久911| 欧美国产日韩亚洲一区| 久久综合网hezyo| 欧美国产日本在线| 国产精品美女www爽爽爽视频| 99精品免费视频| 性娇小13――14欧美| 狠狠色丁香婷综合久久| 欧美国产综合| 午夜精品在线观看| 欧美激情综合色| 亚洲欧美日韩久久精品| 韩国欧美一区| 欧美日韩亚洲激情| 欧美呦呦网站| 亚洲欧洲在线一区| 久久电影一区| 亚洲毛片网站| 国产三级欧美三级日产三级99| 久久久久免费视频| 一区二区三区欧美亚洲| 狂野欧美一区| 亚洲在线视频一区| 亚洲国语精品自产拍在线观看| 国产精品视频yy9299一区| 免费中文字幕日韩欧美| 亚洲欧美中文字幕| 亚洲美女毛片| 欧美1区视频| 欧美在线看片| 99国产精品视频免费观看一公开| 国产亚洲精品久| 欧美日韩黄色大片| 蜜桃av一区二区在线观看| 亚洲欧美日韩一区二区在线| 亚洲欧洲一区| 暖暖成人免费视频| 欧美一区二区福利在线| 一区二区不卡在线视频 午夜欧美不卡'| 国产老肥熟一区二区三区| 欧美乱人伦中文字幕在线| 久久久亚洲一区| 欧美在线观看www| 亚洲一区二区成人| 日韩一级欧洲| 日韩系列欧美系列|