Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Python Programming Language Jeff Myers Programming Language Concepts, 01/14/2002

Similar presentations


Presentation on theme: "The Python Programming Language Jeff Myers Programming Language Concepts, 01/14/2002"— Presentation transcript:

1 The Python Programming Language Jeff Myers Programming Language Concepts, 01/14/2002 http://milly.rh.rit.edu/python/

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/http://www.python.org/ Jython homepage: http://www.jython.org/http://www.jython.org/ Programming Python and Learning Python: http://python.oreilly.com/ http://python.oreilly.com/ This presentation is available from http://milly.rh.rit.edu/python/ http://milly.rh.rit.edu/python/


Download ppt "The Python Programming Language Jeff Myers Programming Language Concepts, 01/14/2002"

Similar presentations


Ads by Google