Python Notes

Notes from CS169:

  • The Python null value is None.
  • Python is dynamically and strongly typed.
  • When you want to use functions defined in imported modules, you need to include the module name: module_name.function_name()
  • Comma-delimited arguments to print in Python prints all the arguments delimited by a space.
  • Python does not allow in-line assignment, so there is no chance of accidentally changing the value of a variable you meant to use in a comparison.
  • When a module is imported, the value of __name__ is its filename. When you execute the module directly, its value is __main__. This allows you to seamlessly embed a test suite right into your code.
  • Dictionary keys must be immutable. This means that a tuple, as long as its elements are immutable, may be a key.
  • is a line continuation marker.
  • Python raises an exception if you try to reference a variable that hasn’t been assigned a value.
  • To get around the strongly-typed aspect of Python, you can use string formatting using tuples.
Posted in Python. 1 Comment »