Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jonathan Huelman CSC 415 – Programming Languages

Similar presentations


Presentation on theme: "Jonathan Huelman CSC 415 – Programming Languages"— Presentation transcript:

1 Jonathan Huelman CSC 415 – Programming Languages
Python Jonathan Huelman CSC 415 – Programming Languages

2 Introduction to Python
Defined as a very high-level scripting language, there isn’t a lot Python can’t do with it’s extensive standard library “Batteries included” Python is interpreted, meaning each line is indirectly executed. There is no byte code Named for Monty Python’s Flying Circus, the British sketch comedy TV show

3 Release dates for the major versions:
History of Python Guido Van Rossum, BDFL (Benevolent Dictator For Life) Python based on ABC, first created in the late 1980s The Python Software foundation launched in March 2006 with Van Rossum as President. It is a non-profit organization dedicated to the Python programming language Release dates for the major versions: Python January 1994 Python October 16, 2000 Python December 3, 2008

4 Who Uses Python Graphics Games Web Development Mathematical libraries
Industrial Light and Magic Walt Disney Feature Animation Games Battlefield 2 Civilization 4 Web Development Yahoo Maps Google Linux Weekly News Mathematical libraries Matplotlib, which is like MATLAB NumPy, a language extension that adds support for large and fast, multi-dimensional arrays and matrices PyIMSL Studio is a Python distribution which includes the IMSL Numerical Libraries.

5 The Zen of Python >>> import this The Zen of Python, by Tim Peters 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 aren't 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 you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! >>> 1. Idioms are frequently not straightforwardly portable from another programming language. For example, the idiomatic way to perform an operation on all items in a list in C looks like this: 2. The direct equivalent in Python would be this: 3. That, however, while it works, is not considered Pythonic. It's not an idiom the Python language encourages. We could improve it. A typical idiom in Python to generate all numbers in a list would be to use something like the built-in range() function: 4. This is however not Pythonic either. Here is the Pythonic way, encouraged by the language itself:

6 ‘Pythonic’ Code for (i=0; i < mylist_length; i++)
{ do_something(mylist[i]); } i = 0 while i < mylist_length: do_something(mylist[i]) i += 1 for i in range(mylist_length): do_something(mylist[i]) for element in mylist: do_something(element)

7 The Size of Python

8 Example – Regular Expressions

9 More Examples http://wiki.python.org/moin/SimpleProgra ms
05-password-generator/?in=lang-python Primes program beers on the wall and a more ‘pythonic’ version Guessing game

10 Pros on Python Why Reddit uses Python
“The biggest thing that has kept us on Python … ... One are the libraries. There’s a library for everything. We’ve been learning a lot of these technologies and a lot of these architectures as we go. The other thing that keeps us on Python, and this is the major thing, is how readable and writable it is. When we hire new employees ... it’s awesome because I can see from across the room, looking at their screen, whether their code is good or bad. Because good Python code has a very obvious structure.” - Steve Huffman, Web Developer, Co-Founder of Reddit.com

11 Evaluation very clear, readable syntax, once you get used to the fact that indentation is key to syntax intuitive object orientation natural expression of procedural code full modularity, supporting hierarchical packages exception-based error handling very high level dynamic data types extensive standard libraries and third party modules for virtually every task embeddable within applications as a scripting interface free, with relatively cheap IDEs available on the Internet

12 Sources http://faassen.n--tree.net/blog/view/weblog/2005/08/06/0


Download ppt "Jonathan Huelman CSC 415 – Programming Languages"

Similar presentations


Ads by Google