781 likes | 1.23k Views
Python Programming Language. Python Programming Language. Created in 1991 by Guido Van Rossum. Python Programming Language. General Purpose Language Clean Syntax. Python Programming Language. General Purpose Language Clean Syntax Easy to Learn. Python Programming Language.
E N D
Python Programming Language • Created in 1991 by Guido Van Rossum
Python Programming Language • General Purpose Language • Clean Syntax
Python Programming Language • General Purpose Language • Clean Syntax • Easy to Learn
Python Programming Language • General Purpose Language • Clean Syntax • Easy to Learn • Easy to Debug
Python Programming Language • General Purpose Language • Clean Syntax • Easy to Learn • Easy to Debug • “Natural Feeling”
Python Programming Language • General Purpose Language • Interpreted
Python Programming Language • General Purpose Language • Interpreted • No Compilation Phase
Python Programming Language • General Purpose Language • Interpreted • No Compilation Phase • Multiplatform Integration
Python Programming Language • General Purpose Language • Interpreted • No Compilation Phase • Multiplatform Integration • Native Debugger
Python Programming Language • General Purpose Language • Interpreted • Duck Typing
Python Programming Language • General Purpose Language • Interpreted • Duck Typing • Override behaviours by creating methods
Python Programming Language • General Purpose Language • Interpreted • Duck Typing • Override behaviours by creating methods • Implement operations by creating methodst
Python Programming Language • General Purpose Language • Interpreted • Duck Typing • Override behaviours by creating methods • Implement operations by creating methods • All data is an object
Python Programming Language • Objects are Python’s abstraction for data. All data in a Python program is represented by objects or by relations between objects. • Every object has an identity, a type and a value.
Python Programming Language • An object’s identity never changes once it has been created • The ‘is‘ operator compares the identity of two objects • The id() function returns an integer representing its identity
Python Programming Language • An object’s identity never changes once it has been created • The ‘is‘ operator compares the identity of two objects • The id() function returns an integer representing its identity • An object’s type is also unchangeable. • The type() function returns an object’s type (which is an object itself).
Python Programming Language • General Purpose Language • Interpreted • Duck Typing • Strongly Typed
Python Programming Language • A Python programmer can write in any style they like, using design patterns borrowed from: • Imperative • Declarative • Object Oriented • functional programming The author is free let the problem guide the development of the solution.
class Hello(object): def __init__(self, my_string): self.my_string = my_string def __call__(self, render_func): out_str = 'Hello %s' % self.my_string render_func(out_str) def print_string(string_to_print): print(string_to_print) myHelloWorldClass = Hello('world') myHelloWorldClass(print_string) Python Programming Language • print('hello world')
LISP (define (addn n) (lambda (k) (+ n k))) Functional Example • Java: • public class OuterClass { • // Inner class • class AddN { • AddN(int n) { _n = n; } • int add(int v) { return _n + v; } • private int _n; • } • public AddN createAddN(int var) { • return new AddN(var); • } • } Python addn = lambda n: lambda x: x + n Or def addN(n): def add_n(x): return x + n return add_n
The standard Python interpreter (CPython) is written in C89 It is designed with two-way interfacing in mind: Embedding C programs in Python Embedding Python programs in C Modular Design
An Example C Module #include <Python.h> static PyObject * spam_system(PyObject *self, PyObject *args) { const char *command; int sts; if (!PyArg_ParseTuple(args, "s", &command)) return NULL; sts = system(command); return Py_BuildValue("i", sts); } /********************************************************* ** import spam ** ** spam.system( ** ** 'find . -name "*.py" ** ** -exec grep -Hn "Flying Circus" {} \;') ** *********************************************************/ Modular Design
The CPython interpreter can be built on most platforms with a standard C library including glibc and uclibc. Cross Platform Execution
Interpreters such as Jython and IronPython can be used to run a python interpreter on any Java or .NET VM respectively. Cross Platform Execution
Protyping Python Is Good For
Protyping Web Applications/SAS Python Is Good For
Protyping Web Applications/SAS Integration Python Is Good For
Protyping Web Applications/SAS Integration Transport Limited Applications Python Is Good For
Protyping Web Applications/SAS Integration Transport Limited Applications Indeterminate Requirements Python Is Good For
Protyping Web Applications/SAS Integration Transport Limited Applications Indeterminate requirements Short Relevence Lifetime Python Is Good For
Protyping Web Applications/SAS Integration Transport Limited Applications Indeterminate requirements Short Relevence Lifetime Porting Legacy Applications Python Is Good For
Protyping Web Applications/SAS Integration Transport Limited Applications Indeterminate requirements Short Relevence Lifetime Porting Legacy Applications Glue Python Is Good For
Native Cryptography Python is Not Good For
Native Cryptography MILOR Python is Not Good For
Native Cryptography MILOR Highly Parallel Design Python is Not Good For
None __Types__
None NotImplemented __Types__
None NotImplemented Boolean __Types__
None NotImplemented Boolean Int/LongInt __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... __Types__
Sequences string unicode bytes tuple list set frozenset __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... Mapping Types (dict) __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... Mapping Types (dict) Functions and Methods __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... Mapping Types (dict) Functions and Methods Generators __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... Mapping Types (dict) Functions and Methods Generators Modules __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... Mapping Types (dict) Functions and Methods Generators Modules File/Buffer __Types__
None NotImplemented Boolean Int/LongInt Float (which is really a double) Complex (double +doubleJ) Sequences... Mapping Types (dict) Functions and Methods Generators Modules File/Buffer Type (metaclasses) __Types__