文章目錄
- HTML Tags and JavaScript tutorial
HTML Tags and JavaScript tutorial
Python Effective Programming
These are some experiences of effective python programming that shown in a slide (
http://www.interlink.com.au/anthony/tech/talks/OSCON2005/effective_r27.pdf
) on OSCON 2005 by Anthony Baxter (
anthony@interlink.com.au
). Most of them are of great value I found in everyday's python programming. So I would like to show them here step by step. Thank Anthony and python that they give us interesting experiences in coding in which sometimes there are lots of boring affairs.
First of all we should define what is effective programming. Someone would say that it is rapid design, fast coding, no bug, excellent speed and etc. Yes, all of above are elements of great code. But one of the most important and basic things is to get the job done correctly. However fast it runs, wrong is wrong.
Maintainability is another key point. Indentation (fortunately this is a nature-born feature of python), meaningful and appropriate comments, consistent naming and clear flow control make up good readability. Code is always on change during the whole procedure of development and it is frustrated when you found that you can not get the meaning of code you wrote and have to read it line by line.
Besides of correct logic and nice design, using language's strengths is a tricky way to make the two above point easier and more effective. Python is a language different from C, Perl, Java, Lisp and etc. It has learned a lot from other languages to extent itself during a long time of growth. It has become another C that can do nearly everything from little scripts to huge system and frameworks. Just like C++, you could code in multiple styles: C style, using basic flow control and data structure, somewhat like a super assembly; C++ style or Java style, classical OO style, everything is object, inheritance and polymorphism everywhere; Lisp or Haskell style, functional, charming and complex; Or Perl style, short, mysterious and complicated, $$$$$$$$. But python has its own style: a nice, clear and elegant. To write python code in this way, a deep understand of all most python features is needed. And then effectiveness would come from your code naturally.
MSN Space Link:
http://vanzolo.spaces.msn.com/blog/cns!4A43F3D396FBF12F!1534.entry?_c11_blogpart_blogpart=blogview&_c=blogpart#permalink