Friday, January 20, 2012

Python's Doc Tutorial Notes

Chapter 1: Whetting Your Appetite

Python is really simple to use, but at the same time it offer more structure and support for large program. In particular, the error checking is very well developed compare to C. Where in C, they expect you to make judgement yourself, and handle the possible problem yourself. And of course, Python has a lot of high-level data types built in, such as flexible array and dictionaries, which can be apply to all types, even your own class. Similar to C++'s vector, you can put your class object into the vector.

Python follows the main heart idea of OOP, it allows user to separate and export their program into modules. And then you can reuse or extend it as needed. There are quite a few module that comes standard with all the python installation, such as file I/O, system calls, sockets, and graphical user interface toolkit such as tkinter.

Python is an interpreted language, so you don't have to worry about comilating and linking your file. Remember when you write a c program, instead of just pressing a "run" button, or F5 in the default IDE, you will instead go to your terminal, type in: g++ -Wall -o csci133p1 csci133p1.cpp ccsci133myClass.cpp. These sort of goodies, after you type them, and then you are hit with a wall of error message that is not very human-readable, but except telling you line number x is broken?

And a couple of key note-worthy characteristic:
  1. Python can do complex operations in 1 liner, and in fact most python programmer love the 1 liner solutions a lot.
  2. Python's statement grouping is done by indentation, instead of the ending brackets {}
  3. There are no variable type declaration, and similarly, there is no return type specified. You can return as many things as your heart desire, by doing return my_number, my_home, my_food

Python's name has nothing to do with the reptiles, it is because the author like the BBC show "Monty Python's Flying Cirus". But despite reading this, I still think about python as "a big snake". :)

Chapter 2.1 Notes

No comments:

Post a Comment