1 / 10

Python

Python. Joseph Eckstrom , Benjamin Moore, Willis Kornegay. Overview. Written to improve programmer productivity Python gives programmers the option to use object-oriented, structured or functional programming paradigms. Trades some speed for productivity In era of fast machines, acceptable.

cheri
Télécharger la présentation

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 Joseph Eckstrom, Benjamin Moore, Willis Kornegay

  2. Overview • Written to improve programmer productivity • Python gives programmers the option to use object-oriented, structured or functional programming paradigms. • Trades some speed for productivity • In era of fast machines, acceptable

  3. History • Written at CWI, Netherlands, by Guido van Rossum • Named BDFL, or “Benevolent Dictator for Life” by Python community • Based on ABC, but ABC had drawbacks • Monolithic design not adaptable • Could not access file system or O.S.

  4. Evolution • Python 1.0 • Classes, inheritance, functional programming • Python 2.0 • Garbage collection, list comprehensions, Haskell-like syntax • Python 3.0 • Refinement of existing features, overhauls to standard libraries

  5. Language Concepts • High level, interpreted language • Supports multiple paradigms • OO, Imperative, Functional • No semicolons at the end of lines • Blocks represented by indentations

  6. Examples of Use – Lambda Functions >>> defmake_incrementor (n): return lambda x: x + n ... >>> f = make_incrementor(2) >>> g = make_incrementor(6) >>> print(f(42), g(42)) 44 48 >>> print(make_incrementor(22)(23)) 45

  7. Examples of Use – Lists >>> S = [x**2 for x in range(10)] >>> V = [2**i for i in range(13)] >>> M = [x for x in S if x % 2 ==0] >>> print(S); print(V); print(M) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096] [0, 4, 16, 36, 64]

  8. Examples of Use – Classes >>> class MyClass: ... # A simple example class … i= 12345 … deff(self): … return “Hello, world.” … >>> x = Myclass() >>> x.f() Hello, world.

  9. Comparison - Ruby • Both imperative/functional, object oriented, & interpreted • Python emphasizes a single best way, and features extensive standard libraries • Ruby emphasizes elegant syntax & greater object-orientation

  10. Comparison – C++ • Both object-oriented, imperative languages • C++ compiled to hardware native code; Python compiled to bytecode, executed by VM • Both languages are flexible in terms of object-orientation.

More Related