Introduction to Python“To describe something as clever is NOT considereda compliment in the Python culture.” Alex Martelli, PythonCookbook (2nd ed., p. 230) Prepared by: Amgad Mohamed | Hussein Mohamed | Yasser Mohsen
Brief Introduction– Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability.– Python claims to "combine remarkable power with very clear syntax", along with a huge standard library with the uniqueness of using indentation as a block delimiters.– Python had three major releases to support multiple programming paradigms including Object Oriented Programming, Imperative programming and Functional programming. Additionally, it features a fully dynamic typing systems and automatic garbage collection.
Quick History– Python was conceived in the late 1980s, and its implementation was started in December 1989 by Guido van Rossum.– Python 2.0 was released on 16 October 2000, with many major new features including a full garbage collector and support for Unicode.– Python 3.0 (also known as Python 3000 or py3k), a major, backwards-incompatible release, was released on 3 December 2008. • Python 3.0 was developed with the same philosophy as in prior versions. However, as Python had accumulated new and redundant ways to program the same task, Python 3.0 had an emphasis on removing duplicative constructs and modules, in keeping with "There should be one and preferably only one obvious way to do it".
Advantages / Disadvantages I. Supports multiple paradigms. II. Less code To Achieve More (Expressiveness) III. Support Libraries (Extendibility) IV. High productivity A. Less time to code and since there is no compilation step; the edit- test-debug cycle is incredibly fast. B. Anecdotal evidence suggests that one Python programmer can finish in two months what two C++ programmers cant complete in a year, Python code is often 5-10 times shorter than equivalent C++ code. C. Python programs are typically 3-5 times shorter than equivalent Java programs. V. Auto Memory Management and Exception Handling.I. Compared to other programming languages, Python performance (timeand space), is way behind, Hard to Translate, and lack of documentation.
Translation– Python Code is compiled to byte code similar to Java, and then this Byte code is interpreted to the underlying machine language. (Pseudo Interpreter)– This byte code provides • portability. • speed execution - byte code can be run much more quickly than the original source code
Sample Code - GCDdef gcd(a, b): "greatest common divisor" while a != 0: a, b = b%a, a # parallel assignment return b
Zen of Python (Easter Egg)• Beautiful is better than ugly.• Explicit is better than implicit.• Simple is better than complex.• Complex is better than complicated.• Flat is better than nested.• Sparse is better than dense.• Readability counts.• Special cases arent special enough to break the rules.• Although practicality beats purity.• Errors should never pass silently• Unless explicitly silenced.• In the face of ambiguity, refuse the temptation to guess.• There should be one-- and preferably only one --obvious way to do it.• Although that way may not be obvious at first unless youre Dutch.• Now is better than never.• Although never is often better than *right* now.• If the implementation is hard to explain, its a bad idea.• If the implementation is easy to explain, it may be a good idea.• Namespaces are one honking great idea -- lets do more of those!
References•  http://docs.python.org/faq/general.html#what-is-python-good-for. Retrieved 2011-10-04•  http://www.python.org/doc/essays/blurb/ Python documentation. Retrieved 2011-10-04.•  http://docs.python.org/faq/general#what-is-python Retrieved 2011-10-04•  http://www.artima.com/intv/pythonP.html Retrieved 2011-10-04•  http://docs.python.org/license.html Retrieved 2011-10-04•  http://python.org/download/releases/3.0/ Retrieved 2011-10-04• http://ugweb.cs.ualberta.ca/~c410/F07/410/presentations/ReportP ython.pdf•  Learning Python 4th Ed, Mark Lutz•  Core Python Programming 2nd Edition, Wesley J. Chun - Sep 2006•  Python Enhancement Proposals, 20 -- The Zen of Python.