1. Python Objects
  2. Internal Types
  3. Standard Types
  4. Object Identity Comparison
  5. Boolean
    1. Standard Type Operators
  6. Object Value Comparison
  7. Object Attributes
  8. Other Built-In Types
  9. Standard Type Built-In Functions
  10. Type Factory Functions
  11. Categorizing the Standard Types
  12. Unsupported Types
  13. - char (Not for single or 8 bit) - pointer (Python manages memory for you) - int versus short versus long (Use plain integers) - float versus double (single precision not supported) - use decimal float
  14. IDENTITY list = [1,2,3] id(list[0]) 30796824L
  15. Identity : id () BIF Type: type() BIF Value: Data Item
  16. TYPES type([]) <type 'list'> type({}) <type 'dict'> type (' ') <type 'str'> type(0) <type 'int'> .......example f = () type(f) <type 'tuple'>
  17. Functions
  18. Methods
  19. Data Attributes Classes, Class Instances, Modules, Complex Numbers and files
  20. Numbers (var1 = 10) ==================================================== - Type int(x)to convert x to a plain integer. - Type long(x) to convert x to a long integer. ex. long(var1) - Type float(x) to convert x to a floating-point number. - Type complex(x) to convert x to a complex number with real part x and imaginary part zero. - Type complex(x, y) to convert x and y to a complex number with real part x and imaginary part y. x and y are numeric expressions ==================================================== Integers Boolean Long Integer Floating Points Complex Number String List Tuple Dictionary
  21. - Type >>>type(42) - Null Object (None) x = None (Set Boolean to False) - File - Set/Frozenset ex cities = set(("Paris", "Lyon", "London","Berlin","Paris","Birmingham")) - Function/Method - Module - Class
  22. - Code Objects- Byte Compiled. ex:Create an Object as follow: compile('sum([1, 2, 3])', '', 'single') or exec compile('sum([1, 2, 3])', '', 'single') or to obtain a function's code object: def f(s): print s and fenter a new line and then type: f.__code__ - Frame Objects - Traceback Objects - Slice Objects Create: sl = slice(0,4) ... Use: s = "ABCDEFGHIJKL" followed by sl = slice(0,4) and then print out: print s[sl] - Ellipsis - Xrange xrange() ex: for i in xrange(10): ... print(i)
  23. 2 == 2 2.46 <= 8.33 5+4j >= 2-3j 'abc' == 'xyz' 3 < 4 < 7
  24. foo1 = foo2 = 4.3 foo1 = 4.3 (foo2 = foo1) foo1 = 4.3 (foo2 = 1.3 + 3.0) (foo1 is not foo2)
  25. and, or not x, y = 3.1, -1024
  26. cmp() (Compares) a,b = -4, 12 (cmp(a,b) repr() str() type() type(4) type(type(4)) (' ') (Back quote operator) type() and isinstance()
  27. Reduce the number of function calls Only have one call made to type() function: >>> import types >>> if type (num) == types.IntType...
  28. Object Value Comparison vs Object Identity Comparison To be optimal: if type(num) is types.IntType... # or type(0) (Bypass Object Value Comparison if the objects are the same)
  29. Reduce The number of Lookups (Shortcut to find IntType by using from-import) from types import IntType if type(num) is IntType...
  30. Convenience and Style - use isinstance The Boolean function takes an object and a Type Object to return True if the object in question is an instance of one of the type objects
  31. Table 4.5
  32. Factory Producing a Good int(), long(), float(), complex() str(), unicode(), basestring() list(), tuple() type()
  33. dict() bool() set(), frozenset() object() classmethod() staticmethod() super() property() file()
  34. Storage Model (How many objects can be stored in an object of this type) Single Types - atomic or scalar storage Multiple Objects - Container Storage (Compound/Composite)
  35. Table 4.6
  36. Update Model Once created can object be changed? Mutable - Can change object value Immutable - Can not change value
  37. Table 4.7
  38. Table 4.8
  39. Table 4.9 (Categorize Standard Types) Storage - Update - Access ex "What is the difference between lists and tuples? (Update model different)
  40. Access Model How do we access the values of the stored data? - Direct - Sequence - Mapping