1 / 12

The Python Programming Language

The Python Programming Language. Jeff Myers. http://milly.rh.rit.edu/python/. Programming Language Concepts, 01/14/2002. Python Overview. Scripting Language Object-Oriented Portable Powerful Easy to learn and use Mixes good features from Java, Perl and Scheme. Major Uses of Python.

finian
Download Presentation

The Python Programming Language

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. The Python Programming Language Jeff Myers http://milly.rh.rit.edu/python/ Programming Language Concepts, 01/14/2002

  2. Python Overview • Scripting Language • Object-Oriented • Portable • Powerful • Easy to learn and use • Mixes good features from Java, Perl and Scheme

  3. Major Uses of Python • System Utilities • GUIs (Tkinter, gtk, Qt, Windows) • Internet Scripting • Embedded Scripting • Database Programming • Artificial Intelligence • Image Processing

  4. History of Python • Created in 1990 by Guido van Rossum • Named after Monty Python • First public release in 1991 • comp.lang.python founded in 1994 • Open source from the start

  5. Language Features • Object-Oriented • Interpreted • Interactive • Dynamic • Functional • Highly readable

  6. Built-in Object Types • Numbers - 3.1415, 1234, 999L, 3+4j • Strings - 'spam', "guido's" • Lists - [1, [2, 'three'], 4] • Dictionaries - {'food':'spam', 'taste':'yum'} • Tuples - (1, 'spam', 4, 'U') • Files - text = open ('eggs', 'r'). read()

  7. Operators • Booleans: and or not < <= >= > == != <> • Identity: is, is not • Membership: in, not in • Bitwise: | ^ & ~ No ++ -- +=, etc.

  8. String Operators • Concatenation: + • Repeat: * • Index: str[i] • Slice: str[i:j] • Length: len( str ) • String Formatting: "a %s parrot" % 'dead‘ • Iteration: for char in str • Membership: ‘m’ in str

  9. Common Statements • Assignment - curly, moe, larry = 'good', 'bad', 'ugly' • Calls - stdout.write("spam, ham, toast\n") • Print - print 'The Killer', joke • If/elif/else - if "python" in text: print text • For/else - for X in mylist: print X • While/else - while 1: print 'hello' • Break, Continue - while 1: if not line: break • Try/except/finally - try: action() except: print 'action error'

  10. Common Statements • Raise - raise endSearch, location • Import, From - import sys; from sys import stdin • Def, Return - def f(a, b, c=1, d): return a+b+c+d • Class - class subclass: staticData = [] • Global - function(): global X, Y; X = 'new' • Del - del data[k]; del data [i:j]; del obj.attr • Exec - yexec "import" + modName in gdict, ldict • Assert - assert X > Y

  11. Samples • System Utility • Functional Programming • Object Oriented networking

  12. References • Python homepage: http://www.python.org/ • Jython homepage: http://www.jython.org/ • Programming Python and Learning Python: http://python.oreilly.com/ This presentation is available from http://milly.rh.rit.edu/python/

More Related