python and mongodb pdf

112 438 0
python and mongodb pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... ordered sets of objects indexed by non-negative integers and include strings, lists, and tuples Strings are sequences of characters, and lists and tuples are sequences of arbitrary Python objects Strings and tuples are immutable; lists allow insertion, deletion, and substitution of elements All sequences support iteration Table 3.2 shows the operators and methods that you can apply to all sequence types... if not v: break A decorator can also accept arguments Here’s an example: @eventhandler('BUTTON') def handle_button(msg): @eventhandler('RESET') def handle_reset(msg): If arguments are supplied, the semantics of the decorator are as follows: def handle_button(msg): temp = eventhandler('BUTTON') handle_button = temp(handle_button) # Call decorator with supplied arguments # Call the function returned... None; F h Lib fL B and empty lists, tuples, and dictionaries evaluate as false Boolean expressions are evaluated from left to right and consume the right operand only if it’s needed to determine the final value For example, a and b evaluates b only if a is true.This is sometimes known as “short-circuit” evaluation d ff h Lib 5 fL B Program Structure and Control Flow Object Equality and Identity The equality... example: # s and t are two sequences for x,y in zip(s,t): statements zip(s,t) combines sequences s and t into a sequence of tuples (s[0],t[0]), (s[1],t[1]), (s[2], t[2]), and so forth, stopping with the shortest of the sequences s and t should they be of unequal length One caution with zip() is that in Python 2, it fully consumes both s and t, creating a list of tuples For generators and sequences... in Python 3 Multiple exception-handling blocks are specified using multiple except clauses, as in the following example: try: do something except IOError as e: # Handle I/O error except TypeError as e: # Handle Type error except NameError as e: # Handle Name error A single handler can catch multiple exception types like this: try: do something except (IOError, TypeError, NameError) as e: # Handle... exception type (Python 2 only) Most recent exception value (Python 2 only) Most recent exception traceback (Python 2 only) Traceback Objects Traceback objects are created when an exception occurs and contain stack trace inforObject Creation and Destruction mation.When an exception handler is entered, the stack trace can be Internals using the The methods in Table 3.11 create, initialize, andBehaviorinstances... mix byte strings and Unicode together in expressions or comparisons (such as using + to concatenate a byte string and Unicode string or using == to compare mixed strings) In Python 3, mixing string types results in a TypeError exception, but Python 2 attempts to perform an implicit promotion of byte strings to Unicode.This aspect of Python 2 is widely considered to be a design mistake and is often a... operators using the speChapter 4 Operators and Expressions 76 cial methods described in Chapter 3, “Types and Objects.” Chapter 4 Operators and Expressions 74 3.1415926 y = r = '{0:10.2f}'.format(y) The set and frozenset type support a number of common set operations: The result of union, intersection, and difference operations will have the same type as the left-most operand For example, if s is a frozenset,... types.ModuleType object type Built-in function or method Type of built-in types and classes Ancestor of all types and classes User-defined function Class method Module Ancestor of all types and classes Type of built-in types and classes Modules Classes Types Note that object and type appear twice in Table 3.9 because classes and types are both callable as a function Callable Types Callable types represent... of x and y for equality In the case of lists and tuples, all the elements are compared and evaluated as true if they’re of equal value For dictionaries, a true value is returned only if x and y have the same set of keys and all the objects with the same key have equal values.Two sets are equal if they have the same elements, which are compared using equality (==) The identity operators (x is y and x . - 0123.63.69.229 Part 1: Python Part 2: MongoDB Part 3: Python and MongoDB Part 1: Python Contents Polymorphism Dynamic Binding and Duck Typing 122 Static Methods and Class Methods 123 Properties. 5 2 Lexical Conventions and Syntax 25 3 Types and Objects 33 4 Operators and Expressions 65 5 Program Structure and Control Flow 81 6 Functions and Functional Programming 93 7 Classes and Object-Oriented. Debugging, Profiling, and Tuning 181 Documentation Strings and the doctest Module 181 Unit Testing and the unittest Module 183 The Python Debugger and the pdb Module 186 Debugger Commands 187 Debugging

Ngày đăng: 21/06/2014, 23:20

Từ khóa liên quan

Mục lục

  • Python and MongoDB

    • B1

    • BookInSV

    • De xuat tuyen dung nhan su

Tài liệu cùng người dùng

Tài liệu liên quan