Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic.

Similar presentations


Presentation on theme: "The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic."— Presentation transcript:

1 The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic

2 June 2004, Socrates IP... syntax, semantics and examples

3 June 2004, Socrates IP The Python Language 3 Objects are garbage collected l Automatic memory management. l Reference counting. l Cyclic references. l To decrease the reference counter: u rebind to None u use del

4 June 2004, Socrates IP The Python Language 4... example

5 June 2004, Socrates IP The Python Language 5... removing the name

6 June 2004, Socrates IP The Python Language 6 Simple statements l... do not look as function calls: u assignment u print u del u pass (def myFunction: pass) u return u raise u try / except u assert

7 June 2004, Socrates IP The Python Language 7 Built-in functions l Predefined functions, always available: u id() u type() u str() u repr()

8 June 2004, Socrates IP The Python Language 8 Block, indentation, readability l Indentation defines what is inside the block. l The more indent steps, the deeper the block is. l “Life is better without braces” (Eckel) l More strict formatting rules – more readable source. l Even those disgusted by missing braces do like it at the end (at least, no problem – Raymond).

9 June 2004, Socrates IP The Python Language 9 Programming constructions l if – elif – else l while l for

10 June 2004, Socrates IP The Python Language 10 if – elif – else

11 June 2004, Socrates IP The Python Language 11 elif is good... l Replacement for the switch statement:

12 June 2004, Socrates IP The Python Language 12 elif is not necessary

13 June 2004, Socrates IP The Python Language 13 while, the general loop

14 June 2004, Socrates IP The Python Language 14 for – iteration through all items l Not a counted loop. l No direct indexing. l More modern, iterators.

15 June 2004, Socrates IP The Python Language 15 for, simulation of the counted loop

16 June 2004, Socrates IP The Python Language 16 xrange() with step

17 June 2004, Socrates IP The Python Language 17 Functions l They use return: l Arguments are passed by references, any type:

18 June 2004, Socrates IP The Python Language 18 Generators l They use yield; iterators:

19 June 2004, Socrates IP The Python Language 19 Generators and their iterators

20 June 2004, Socrates IP The Python Language 20... iterator

21 June 2004, Socrates IP The Python Language 21 The iteration inside while

22 June 2004, Socrates IP The End of Part II

23 June 2004, Socrates IP The Python Language 23... capturing the exception

24 June 2004, Socrates IP The Python Language 24... continue


Download ppt "The Python Language Petr Přikryl Part IIb Socrates IP, 15th June 2004 TU of Brno, FIT, Czech Republic."

Similar presentations


Ads by Google