Python Libraries, tools and Links | Official Python Docs

Python Language Notes

  1. Lexical Analysis
  2. Keywords
     name      ::=  lc_letter (lc_letter | "_")*
     lc_letter ::=  "a"..."z"
      
  3. Operators and Builtin Functions
    1. All Types
    2. type(obj) --> type object
      
      isinstance(obj, typ) --> bool
      
      repr(obj) #evaluatable representation
      
      str(obj)  #printable representation
      
      is, is not # are two objects the same
  4. Objects
  5. int, float, bool, dict, set, tuple, str, bytes
     None
    functions without return, return None
  6. Classification
  7. Primative Types
  8. Complex
  9.  complex(2,3) #(2+3j)
     
  10. Sequence (Builtin Functions)
  11. len(obj)
  12. Modules and Packages
  13. Standard Library / Types
  14. Converstion Functions
  15. Operators
  16. Expressions
  17.  Operator Precedence
    | no. | operators  | description          |
    |   1 | f(...)     | function application |
    |   2 | o[l]       | index lookups        |
    |   3 | o.f(...)   | method call          |
    |   4 | **         | exponentiation       |
    |   5 | -N         | sign change          |
    |   6 | *,/,//,%   | numeric              |
    |   7 | +,-        | numeric              |
    |   8 | <, <=, ... | comparisons          |
    |   9 | in, not in | membership           |
    |  10 | not o      | logical              |
    |  11 | and 0      | logical              |
    |  12 | or         | logical              |
    
  18. Rules for Well-formedness
  19. Printing
  20.  print("hello", 'how')
     print("hello", end='')
    
     from pprint import *
     pprint(expressions)
    
  21. Functions
  22. A function is a named block of code. Lambda's produce anonymous functions.
  23. Methods
  24.  x+1
    
     [is actually]
    
     x.__add__(1)
    
    Similarly we have the following:
  25. Some Builtins
  26.  abs, min, max
     type
     len
     dir
    gives internal dictionary of names
    
  27. Testing
  28.  Doctests
     test_sqrt.py
    
    """
    >>> sqrt(4)
    2.0
    >>> sqrt(2)
    1.4142135623730951
    >>> sqrt(-1)
    0+1j
    """
    
    from sqrt import *
    
    if __name__ == "__main__":
        import doctest
        doctest.testmod()
    
     sqrt.py
    
    def sqrt(x):
      x**0.5
    
    
  29. Conditionals
  30. if  expr:
      expr
    elif expr:
      expr
    else:
      True
    
    while x:
      expr
        break;
    
    break - takes you out of the loop permanently. continues - takes you to the beginning of the loop again.
  31. Sequence Operations
  32. Classes
  33. User Input
    name = input("what is your name? ")
    

http://thevikidtruth.com/wiki/?python

20sep22   admin