Size: 259
Comment:
|
Size: 1309
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 6: | Line 6: |
<<TableOfContents(2)>> | <<TableOfContents(3)>> = Variable names = Allowed names for identifier (name of variable or function): * Any sequence of alphabetical character, number, or underline character {{{_}}} * First symbol has to be a character * Case sensitive * Not a python built-in keyword == Name space == The Python interpreter maps the name of an identifier in the active name space. The active name space depends on the active code block (module, function). The identifier can be local or global with respect to the active code block. {{{#!python def bad_style(x): # Name space of bad_style global y y=x z=x return x # Name space of __main__ x,y,z=2,2,2 x=bad_style(1) print 'x=',x,'y=',y,'z=',z # y is changed! }}} |
Line 11: | Line 37: |
* Plain integer: {{{9}}} * Long integer: {{{9**99, 1L}}} * Hex integer: {{{0x10}}} * Floating point: {{{0.1}}} * Exponential floating point: {{{1e-3}}} * Complex: {{{3+2j}}} |
|
Line 12: | Line 44: |
== Tuple == | === Casting === |
Line 14: | Line 46: |
== List == | * int() * long() * float() * complex() * str() == Sequences == === String === === Tuple === === List === |
Line 18: | Line 62: |
= Extended data types= | = Extended data types = |
Line 21: | Line 65: |
= Copy and reference = |
Contents
Variable names
Allowed names for identifier (name of variable or function):
Any sequence of alphabetical character, number, or underline character _
- First symbol has to be a character
- Case sensitive
- Not a python built-in keyword
Name space
The Python interpreter maps the name of an identifier in the active name space. The active name space depends on the active code block (module, function). The identifier can be local or global with respect to the active code block.
Built-in
Scalar
Plain integer: 9
Long integer: 9**99, 1L
Hex integer: 0x10
Floating point: 0.1
Exponential floating point: 1e-3
Complex: 3+2j
Casting
- int()
- long()
- float()
- complex()
- str()
Sequences
String
Tuple
List
Dictionary
Extended data types
Array