1 / 12

Python

Python. Jonathan Huelman CSC 415 – Programming Languages. 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”.

naasir
Download Presentation

Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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. 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 1.0 - January 1994 Python 2.0 - October 16, 2000 Python 3.0 - December 3, 2008

  4. Who Uses Python • Graphics • 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! >>>

  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 • http://docs.python.org/library/

  8. Example – Regular Expressions

  9. More Examples • http://wiki.python.org/moin/SimplePrograms • http://code.activestate.com/recipes/577905-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 http://brainsik.theory.org/.:./2009/why-reddit-uses-python http://www.yak.net/fqa/171.html http://www.python.org/ http://en.wikipedia.org/wiki/Python_(programming_language)

More Related