python2.x Study Notes (3)-Python based
# Check conditions
if (weather_is_hot == 1) and \
(Shark_warnings == 0):
There are two exceptions to a statement does not use a backslash can be branched. When using the closure operator in a single statement can span multiple lines, for example: in the presence of parentheses, brackets, braces can be written in more than one line. The other is a string of three quotes can also be included under the Interbank writing.
2. Every Python script file can be treated as a module. Module to the form of a disk file.
3. Multiple assignment
>>> X = y = z = 1
>>> X, y, z = 1, 2, 'a string'
>>> (X, y, z) = (1, 2, 'a string')
Multiple assignment Python way exchange can be achieved without intermediate variable values of two variables
>>> X, y = y, x
4. Keyword keyword list and iskeyword () functions into the keyword
Modules for easy reference. import keyword; dir (keyword)
In addition to keyword addition, Python code also can be used at any level, "built" the name of the collection, these names can be set or used by the interpreter.
5. Special underscore identifiers
_** no 'from module import *' Import
__**__ system-defined name
__** class private variable name
6. Python have a way to run-time detection of the module is being imported or to be directly implemented?
__name__ system variable is the correct answer:
If the module is being imported, __name__ value of the module name if the module is to be directly executed, __name__ value '__main__'
7. Memory management variables without prior declaration need not specify the type of variable programmers do not care about memory management variable name will be "recycled"
del statement to release resources for direct
8. In Python, without explicit variable declaration statement, variable is assigned automatically when the first statement. Like most other languages, variables only be created and assigned before being used.
9. Related modules and development tools
Python coding style guide (PEP8), Python quick reference and developer Python FAQ is very important "tool." In addition, some modules will help you become a good Python programmers.
Profilers: profile, hotshot, cProfile
1. All right, like Python have three characteristics: identity, type and value. Status: Each object has a uniq ...
The following points for 2.7 or older versions, 3.x is applicable in doubt 1, python with a symbol # comments ...
1. Print statement calling str () function display objects, while the interactive interpreter call the repr () ...
1. Python supports a variety of numeric types: integer, long integer, boolean, double-precision floating-point ...
1. File object can be used to access not only to ordinary disk files, and can also access any other type of ab ...
1. When the Python detects an error, the interpreter will be pointed out that the current flow can no longer c ...
1. Standard conditional statement if the syntax is as follows: if expression1: if_suite elif expression2: elif ...
1. The list is to retain any number of Python objects in a flexible container, the list not only contains the ...
1. The dictionary is the only Python language mapping type. Mapping type object Li Haxi value (key) and point ...
1. Regular expressions (RE) for advanced text pattern matching, and search - provides the basis for alternativ ...
1. The concept of keyword parameter called only for the function. This idea is to let the caller by the name o ...
python2.x Study Notes (6) - sequences (strings, lists, tuples)1. We have to think about a number of Python types, ordered arrangement of their members, and can be offset by ...
1. If expression1: expr1_true_suite elif expression2: expr2_true_suite elif expressionN: exprN_true_suite else ...
#coding=UTF-8 ''' Created on 2011-5-18 @author: lingyibin ''' import types import math print 'hello' #append a ...
1. Install python I installed the python2.5 To http://www.python.org/download/ Download python, I use under th ...
Design Pattern personal study notes (2006-12) Design Pattern have to talk about talking about from the multipl ...
Dojo Study Notes (2. DjConfig explain) dojo are djConfig a built-in Global Settings object, its role is throug ...
hibernate-depth study notes Keywords: hibernate o / r maping Hb just in the fire is abuse, seen, but not very ...
XSL Study Notes 3 XSLT template rules <xsl:value-of> and <xsl:for-each> 1, <xsl:value-of> el ...