SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
Python: An Overview
Python: An Overview
What Is Python?
What Is Python?
 Created in 1990 by Guido van Rossum
Created in 1990 by Guido van Rossum
 About the origin of Python, Van Rossum wrote in 1996:
About the origin of Python, Van Rossum wrote in 1996:
 Over six years ago, in December 1989, I was looking for a
Over six years ago, in December 1989, I was looking for a
"hobby" programming project that would keep me occupied
"hobby" programming project that would keep me occupied
during the week around Christmas. My office … would be
during the week around Christmas. My office … would be
closed, but I had a home computer, and not much else on my
closed, but I had a home computer, and not much else on my
hands. I decided to write an interpreter for the new scripting
hands. I decided to write an interpreter for the new scripting
language I had been thinking about lately: a descendant of
language I had been thinking about lately: a descendant of
ABC that would appeal to Unix/C hackers. I chose Python as a
ABC that would appeal to Unix/C hackers. I chose Python as a
working title for the project, being in a slightly irreverent
working title for the project, being in a slightly irreverent
mood (and a big fan of Monty Python's Flying Circus).
mood (and a big fan of Monty Python's Flying Circus).

Is Python A Scripting Language?
Is Python A Scripting Language?
 Usually thought of as one
Usually thought of as one
 But this is mainly a marketing issue
But this is mainly a marketing issue
 People think of scripting languages as being
People think of scripting languages as being
easy to learn, and useful.
easy to learn, and useful.
 But Python is a well worked out coherent
But Python is a well worked out coherent
dynamic programming language
dynamic programming language
 And there is no reason not to use it for a wide
And there is no reason not to use it for a wide
range of applications.
range of applications.
Design Philosophy
Design Philosophy
>>> import this
>>> import this
The Zen of Python, by Tim Peters
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Beautiful is better than ugly.
Explicit is better than implicit.
Explicit is better than implicit.
Simple is better than complex.
Simple is better than complex.
Complex is better than complicated.
Complex is better than complicated.
Flat is better than nested.
Flat is better than nested.
Sparse is better than dense.
Sparse is better than dense.
Readability counts.
Readability counts.
Special cases aren't special enough to break the rules.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Although practicality beats purity.
Errors should never pass silently.
Errors should never pass silently.
Unless explicitly silenced.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Now is better than never.
Although never is often better than *right* now.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Namespaces are one honking great idea -- let's do more of those!
Why Python?
Why Python?
 Designed to be easy to learn and master
Designed to be easy to learn and master
 Clean, clear syntax
Clean, clear syntax
 Very few keywords
Very few keywords
 Highly portable
Highly portable
 Runs almost anywhere - high end servers and
Runs almost anywhere - high end servers and
workstations, down to windows CE
workstations, down to windows CE
 Uses machine independent byte-codes
Uses machine independent byte-codes
 Extensible
Extensible
 Designed to be extensible using C/C++, allowing
Designed to be extensible using C/C++, allowing
access to many external libraries
access to many external libraries
Most obvious and notorious
Most obvious and notorious
features
features
 Clean syntax plus high-level data types
Clean syntax plus high-level data types
 Leads to fast coding (First language in many
Leads to fast coding (First language in many
universities abroad!)
universities abroad!)
 Uses white-space to delimit blocks
Uses white-space to delimit blocks
 Humans generally do, so why not the
Humans generally do, so why not the
language?
language?
 Try it, you will end up liking it
Try it, you will end up liking it
 Variables do not need declaration
Variables do not need declaration
 Although not a type-less language
Although not a type-less language
Productivity!
Productivity!
 Reduced development time
Reduced development time
 code is 2-10x shorter than C, C++, Java
code is 2-10x shorter than C, C++, Java
 Improved program maintenance
Improved program maintenance
 code is extremely readable
code is extremely readable
 Less training
Less training
 language is very easy to learn
language is very easy to learn
What is it used for?
What is it used for?
 rapid prototyping
rapid prototyping
 web scripting
web scripting
 throw-away, ad hoc programming
throw-away, ad hoc programming
 steering scientific applications
steering scientific applications
 extension language
extension language
 XML processing
XML processing
 database applications
database applications
 GUI applications
GUI applications
 A Glue Language
A Glue Language
PYTHON
PYTHON
COMPARED TO
COMPARED TO
OTHER LANGUAGES
OTHER LANGUAGES
Python vs. Perl
Python vs. Perl
 Easier to learn
Easier to learn
 important for occasional users
important for occasional users
 More readable code
More readable code
 improved code maintenance
improved code maintenance
 Fewer “magical” side effects
Fewer “magical” side effects
 More “safety” guarantees
More “safety” guarantees
 Better Java integration
Better Java integration
 Less Unix bias
Less Unix bias
Python vs. Tcl
Python vs. Tcl
 Real datatypes, object-orientation
Real datatypes, object-orientation
 More differentiated syntax
More differentiated syntax
 Much faster (even than Tcl 8.x)
Much faster (even than Tcl 8.x)
 Less need for C extensions
Less need for C extensions
 C extensions don’t redefine syntax
C extensions don’t redefine syntax
 hence fewer extension conflicts
hence fewer extension conflicts
 Better Java integration
Better Java integration
 Python uses Tk as de-facto GUI std
Python uses Tk as de-facto GUI std
Python vs. Java
Python vs. Java
 Code 5-10 times more concise
Code 5-10 times more concise
 Dynamic typing
Dynamic typing
 Much quicker development
Much quicker development
 no compilation phase
no compilation phase
 less typing
less typing
 Yes, it runs slower
Yes, it runs slower
 but development is so much faster!
but development is so much faster!
 Use Python with Java: Jython!
Use Python with Java: Jython!
Python Basics
Python Programs
Python Programs
 Python programs and modules are written
Python programs and modules are written
as text files with traditionally a
as text files with traditionally a .py
.py
extension
extension
 Each Python module has its own discrete
Each Python module has its own discrete
namespace
namespace
 Name space within a Python module is a
Name space within a Python module is a
global one.
global one.
Python Programs
Python Programs
 Python modules and programs are
Python modules and programs are
differentiated only by the way they are
differentiated only by the way they are
called
called
 .py files executed directly are programs (often
.py files executed directly are programs (often
referred to as scripts)
referred to as scripts)
 .py files referenced via the
.py files referenced via the import
import statement
statement
are modules
are modules
Python Programs
Python Programs
 Thus, the same .py file can be a
Thus, the same .py file can be a
program/script, or a module
program/script, or a module
 This feature is often used to provide
This feature is often used to provide
regression tests for modules
regression tests for modules
 When module is executed as a program, the
When module is executed as a program, the
regression test is executed
regression test is executed
 When module is imported, test functionality is
When module is imported, test functionality is
not executed
not executed
Variables and Types
Variables and Types (1 of 3)
(1 of 3)
 Variables need no declaration
Variables need no declaration
 >>> a=1
>>> a=1
>>>
>>>
 As a variable assignment is a statement,
As a variable assignment is a statement,
there is no printed result
there is no printed result
 >>> a
>>> a
1
1
 Variable name alone is an expression, so
Variable name alone is an expression, so
the result is printed
the result is printed
Variables and Types
Variables and Types (2 of 3)
(2 of 3)
 Variables must be created before they can
Variables must be created before they can
be used
be used
 >>> b
>>> b
Traceback (innermost last):
Traceback (innermost last):
File "<interactive input>", line
File "<interactive input>", line
1, in ?
1, in ?
NameError: b
NameError: b
>>>
>>>
 Python uses exceptions - more detail later
Python uses exceptions - more detail later
Variables and Types
Variables and Types (3 of 3)
(3 of 3)
 Objects always have a type
Objects always have a type
 >>> a = 1
>>> a = 1
>>> type(a)
>>> type(a)
<type 'int'>
<type 'int'>
>>> a = "Hello"
>>> a = "Hello"
>>> type(a)
>>> type(a)
<type 'string'>
<type 'string'>
>>> type(1.0)
>>> type(1.0)
<type 'float'>
<type 'float'>
Assignment versus Equality
Assignment versus Equality
Testing
Testing
 Assignment performed with single =
Assignment performed with single =
 Equality testing done with double = (==)
Equality testing done with double = (==)
 Sensible type promotions are defined
Sensible type promotions are defined
 Identity tested with
Identity tested with is
is operator.
operator.
 >>> 1==1
>>> 1==1
1
1
>>> 1.0==1
>>> 1.0==1
1
1
>>> "1"==1
>>> "1"==1
0
0
Simple Data Types
Simple Data Types
 Strings
Strings
 May hold any data, including embedded
May hold any data, including embedded
NULLs
NULLs
 Declared using either single, double, or triple
Declared using either single, double, or triple
quotes
quotes
 >>> s = "Hi there"
>>> s = "Hi there"
>>> s
>>> s
'Hi there'
'Hi there'
>>> s = "Embedded 'quote'"
>>> s = "Embedded 'quote'"
>>> s
>>> s
"Embedded 'quote'"
"Embedded 'quote'"
Simple Data Types
Simple Data Types
 Triple quotes useful for multi-line strings
Triple quotes useful for multi-line strings
 >>> s = """ a long
>>> s = """ a long
... string with "quotes" or
... string with "quotes" or
anything else"""
anything else"""
>>> s
>>> s
' a long012string with "quotes" or
' a long012string with "quotes" or
anything else'
anything else'
>>> len(s)
>>> len(s)
45
45
Simple Data Types
Simple Data Types
 Integer objects implemented using C
Integer objects implemented using C
longs
longs
 Like C, integer division returns the floor
Like C, integer division returns the floor
 >>> 5/2
>>> 5/2
2
2
 Float types implemented using C doubles
Float types implemented using C doubles
 No point in having single precision since
No point in having single precision since
execution overhead is large anyway
execution overhead is large anyway
Simple Data Types
Simple Data Types
 Long Integers have unlimited size
Long Integers have unlimited size
 Limited only by available memory
Limited only by available memory
 >>> long = 1L << 64
>>> long = 1L << 64
>>> long ** 5
>>> long ** 5
21359870359209100823950217061695521146027045223
21359870359209100823950217061695521146027045223
56652769947041607822219725780640550022962086936
56652769947041607822219725780640550022962086936
576L
576L
High Level Data Types
High Level Data Types
 Lists hold a sequence of items
Lists hold a sequence of items
 May hold any object
May hold any object
 Declared using square brackets
Declared using square brackets
 >>> l = []# An empty list
>>> l = []# An empty list
>>> l.append(1)
>>> l.append(1)
>>> l.append("Hi there")
>>> l.append("Hi there")
>>> len(l)
>>> len(l)
2
2
High Level Data Types
High Level Data Types
 >>> l
>>> l
[1, 'Hi there']
[1, 'Hi there']
>>>
>>>
>>> l = ["Hi there", 1, 2]
>>> l = ["Hi there", 1, 2]
>>> l
>>> l
['Hi there', 1, 2]
['Hi there', 1, 2]
>>> l.sort()
>>> l.sort()
>>> l
>>> l
[1, 2, 'Hi there']
[1, 2, 'Hi there']
High Level Data Types
High Level Data Types
 Tuples are similar to lists
Tuples are similar to lists
 Sequence of items
Sequence of items
 Key difference is they are immutable
Key difference is they are immutable
 Often used in place of simple structures
Often used in place of simple structures
 Automatic unpacking
Automatic unpacking
 >>> point = 2,3
>>> point = 2,3
>>> x, y = point
>>> x, y = point
>>> x
>>> x
2
2
High Level Data Types
High Level Data Types
 Tuples are particularly useful to return
Tuples are particularly useful to return
multiple values from a function
multiple values from a function
 >>> x, y = GetPoint()
>>> x, y = GetPoint()
 As Python has no concept of byref
As Python has no concept of byref
parameters, this technique is used widely
parameters, this technique is used widely
High Level Data Types
High Level Data Types
 Dictionaries hold key-value pairs
Dictionaries hold key-value pairs
 Often called maps or hashes. Implemented
Often called maps or hashes. Implemented
using hash-tables
using hash-tables
 Keys may be any immutable object, values
Keys may be any immutable object, values
may be any object
may be any object
 Declared using braces
Declared using braces
 >>> d={}
>>> d={}
>>> d[0] = "Hi there"
>>> d[0] = "Hi there"
>>> d["foo"] = 1
>>> d["foo"] = 1
High Level Data Types
High Level Data Types
 Dictionaries (cont.)
Dictionaries (cont.)
 >>> len(d)
>>> len(d)
2
2
>>> d[0]
>>> d[0]
'Hi there'
'Hi there'
>>> d = {0 : "Hi there", 1 :
>>> d = {0 : "Hi there", 1 :
"Hello"}
"Hello"}
>>> len(d)
>>> len(d)
2
2
Blocks
Blocks
 Blocks are delimited by indentation
Blocks are delimited by indentation
 Colon used to start a block
Colon used to start a block
 Tabs or spaces may be used
Tabs or spaces may be used
 Maxing tabs and spaces works, but is
Maxing tabs and spaces works, but is
discouraged
discouraged
 >>> if 1:
>>> if 1:
...
... print "True"
print "True"
...
...
True
True
>>>
>>>
Blocks
Blocks
 Many hate this when they first see it
Many hate this when they first see it
 Most Python programmers come to love it
Most Python programmers come to love it
 Humans use indentation when reading
Humans use indentation when reading
code to determine block structure
code to determine block structure
 Ever been bitten by the C code?:
Ever been bitten by the C code?:
 if (1)
if (1)
printf("True");
printf("True");
CallSomething();
CallSomething();
Looping
Looping
 The
The for
for statement loops over sequences
statement loops over sequences
 >>> for ch in "Hello":
>>> for ch in "Hello":
...
... print ch
print ch
...
...
H
H
e
e
l
l
l
l
o
o
>>>
>>>
Looping
Looping
 Built-in function
Built-in function range()
range() used to build
used to build
sequences of integers
sequences of integers
 >>> for i in range(3):
>>> for i in range(3):
... print i
... print i
...
...
0
0
1
1
2
2
>>>
>>>
Looping
Looping
 while
while statement for more traditional
statement for more traditional
loops
loops
 >>> i = 0
>>> i = 0
>>> while i < 2:
>>> while i < 2:
... print i
... print i
... i = i + 1
... i = i + 1
...
...
0
0
1
1
>>>
>>>
Functions
Functions
 Functions are defined with the
Functions are defined with the def
def
statement:
statement:
 >>> def foo(bar):
>>> def foo(bar):
... return bar
... return bar
>>>
>>>
 This defines a trivial function named
This defines a trivial function named foo
foo
that takes a single parameter
that takes a single parameter bar
bar
Functions
Functions
 A function definition simply places a
A function definition simply places a
function object in the namespace
function object in the namespace
 >>> foo
>>> foo
<function foo at fac680>
<function foo at fac680>
>>>
>>>
 And the function object can obviously be
And the function object can obviously be
called:
called:
 >>> foo(3)
>>> foo(3)
3
3
>>>
>>>
Classes
Classes
 Classes are defined using the
Classes are defined using the class
class
statement
statement
 >>> class Foo:
>>> class Foo:
... def __init__(self):
... def __init__(self):
... self.member = 1
... self.member = 1
... def GetMember(self):
... def GetMember(self):
... return self.member
... return self.member
...
...
>>>
>>>
Classes
Classes
 A few things are worth pointing out in the
A few things are worth pointing out in the
previous example:
previous example:
 The constructor has a special name
The constructor has a special name
__init__
__init__, while a destructor (not shown)
, while a destructor (not shown)
uses
uses __del__
__del__
 The
The self
self parameter is the instance (ie, the
parameter is the instance (ie, the
this
this in C++). In Python, the self parameter
in C++). In Python, the self parameter
is explicit (c.f. C++, where it is implicit)
is explicit (c.f. C++, where it is implicit)
 The name
The name self
self is not required - simply a
is not required - simply a
convention
convention
Classes
Classes
 Like functions, a class statement simply
Like functions, a class statement simply
adds a class object to the namespace
adds a class object to the namespace
 >>> Foo
>>> Foo
<class __main__.Foo at 1000960>
<class __main__.Foo at 1000960>
>>>
>>>
 Classes are instantiated using call syntax
Classes are instantiated using call syntax
 >>> f=Foo()
>>> f=Foo()
>>> f.GetMember()
>>> f.GetMember()
1
1
Modules
Modules
 Most of Python’s power comes from
Most of Python’s power comes from
modules
modules
 Modules can be implemented either in
Modules can be implemented either in
Python, or in C/C++
Python, or in C/C++
 import
import statement makes a module
statement makes a module
available
available
 >>> import string
>>> import string
>>> string.join( ["Hi", "there"] )
>>> string.join( ["Hi", "there"] )
'Hi there'
'Hi there'
>>>
>>>
Exceptions
Exceptions
 Python uses exceptions for errors
Python uses exceptions for errors
 try
try /
/ except
except block can handle exceptions
block can handle exceptions
 >>> try:
>>> try:
... 1/0
... 1/0
... except ZeroDivisionError:
... except ZeroDivisionError:
... print "Eeek"
... print "Eeek"
...
...
Eeek
Eeek
>>>
>>>
Exceptions
Exceptions
 try
try /
/ finally
finally block can guarantee
block can guarantee
execute of code even in the face of
execute of code even in the face of
exceptions
exceptions
 >>> try:
>>> try:
... 1/0
... 1/0
... finally:
... finally:
... print "Doing this anyway"
... print "Doing this anyway"
...
...
Doing this anyway
Doing this anyway
Traceback (innermost last): File "<interactive
Traceback (innermost last): File "<interactive
input>", line 2, in ?
input>", line 2, in ?
ZeroDivisionError: integer division or modulo
ZeroDivisionError: integer division or modulo
>>>
>>>
Threads
Threads
 Number of ways to implement threads
Number of ways to implement threads
 Highest level interface modelled after
Highest level interface modelled after
Java
Java
 >>> class DemoThread(threading.Thread):
>>> class DemoThread(threading.Thread):
... def run(self):
... def run(self):
... for i in range(3):
... for i in range(3):
... time.sleep(3)
... time.sleep(3)
... print i
... print i
...
...
>>> t = DemoThread()
>>> t = DemoThread()
>>> t.start()
>>> t.start()
>>> t.join()
>>> t.join()
0
0
1
1 <etc>
<etc>
Standard Library
Standard Library
 Python comes standard with a set of modules,
Python comes standard with a set of modules,
known as the “standard library”
known as the “standard library”
 Incredibly rich and diverse functionality available
Incredibly rich and diverse functionality available
from the standard library
from the standard library
 All common internet protocols, sockets, CGI, OS
All common internet protocols, sockets, CGI, OS
services, GUI services (via Tcl/Tk), database,
services, GUI services (via Tcl/Tk), database,
Berkeley style databases, calendar, Python
Berkeley style databases, calendar, Python
parser, file globbing/searching, debugger,
parser, file globbing/searching, debugger,
profiler, threading and synchronisation,
profiler, threading and synchronisation,
persistency, etc
persistency, etc
External library
External library
 Many modules are available externally
Many modules are available externally
covering almost every piece of
covering almost every piece of
functionality you could ever desire
functionality you could ever desire
 Imaging, numerical analysis, OS specific
Imaging, numerical analysis, OS specific
functionality, SQL databases, Fortran
functionality, SQL databases, Fortran
interfaces, XML, Corba, COM, Win32 API,
interfaces, XML, Corba, COM, Win32 API,
comedilib, serial, parallel, opengl, opencv,
comedilib, serial, parallel, opengl, opencv,
wxpython, gtk, qt, tkinter etc
wxpython, gtk, qt, tkinter etc
 Way too many to give the list any justice
Way too many to give the list any justice
More Information on Python
More Information on Python
 Comes with extensive documentation,
Comes with extensive documentation,
including tutorials and library reference
including tutorials and library reference
 Also a number of Python books available
Also a number of Python books available
 Visit
Visit www.python.org
www.python.org for more details
for more details
 Can find python tutorial and reference manual
Can find python tutorial and reference manual

Mais conteúdo relacionado

Mais procurados

JavaScript Speech Recognition
JavaScript Speech RecognitionJavaScript Speech Recognition
JavaScript Speech RecognitionFITC
 
Spring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good partsSpring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good partsJarek Ratajski
 
Jariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinJariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinFederico Tomassetti
 
Dart: A Replacement for JavaScript and Why You Should Care
Dart: A Replacement for JavaScript and Why You Should CareDart: A Replacement for JavaScript and Why You Should Care
Dart: A Replacement for JavaScript and Why You Should CareKevin Gisi
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaEdureka!
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No RegretsAlex Ezell
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Edureka!
 
Why I Love Python V2
Why I Love Python V2Why I Love Python V2
Why I Love Python V2gsroma
 
Python presentation
Python presentationPython presentation
Python presentationgaganapponix
 
The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.2 book - Part 77 of 84The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.2 book - Part 77 of 84Mahmoud Samir Fayed
 
Java And Community Support
Java And Community SupportJava And Community Support
Java And Community SupportWilliam Grosso
 
ICDM 2019 Tutorial: Speech and Language Processing: New Tools and Applications
ICDM 2019 Tutorial: Speech and Language Processing: New Tools and ApplicationsICDM 2019 Tutorial: Speech and Language Processing: New Tools and Applications
ICDM 2019 Tutorial: Speech and Language Processing: New Tools and ApplicationsForward Gradient
 
Python an-intro v2
Python an-intro v2Python an-intro v2
Python an-intro v2Arulalan T
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem Claudson Oliveira
 
Invasion of the dynamic language weenies
Invasion of the dynamic language weeniesInvasion of the dynamic language weenies
Invasion of the dynamic language weeniesSrijit Kumar Bhadra
 
Can Python Overthrow Java? | Java vs Python | Edureka
Can Python Overthrow Java? | Java vs Python | EdurekaCan Python Overthrow Java? | Java vs Python | Edureka
Can Python Overthrow Java? | Java vs Python | EdurekaEdureka!
 
The Ring programming language version 1.7 book - Part 89 of 196
The Ring programming language version 1.7 book - Part 89 of 196The Ring programming language version 1.7 book - Part 89 of 196
The Ring programming language version 1.7 book - Part 89 of 196Mahmoud Samir Fayed
 
Python an-intro youtube-livestream-day1
Python an-intro youtube-livestream-day1Python an-intro youtube-livestream-day1
Python an-intro youtube-livestream-day1MAHALAKSHMI P
 

Mais procurados (20)

JavaScript Speech Recognition
JavaScript Speech RecognitionJavaScript Speech Recognition
JavaScript Speech Recognition
 
Spring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good partsSpring, CDI, Jakarta EE good parts
Spring, CDI, Jakarta EE good parts
 
Why Ruby
Why RubyWhy Ruby
Why Ruby
 
Jariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinJariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlin
 
Dart: A Replacement for JavaScript and Why You Should Care
Dart: A Replacement for JavaScript and Why You Should CareDart: A Replacement for JavaScript and Why You Should Care
Dart: A Replacement for JavaScript and Why You Should Care
 
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | EdurekaPython Course | Python Programming | Python Tutorial | Python Training | Edureka
Python Course | Python Programming | Python Tutorial | Python Training | Edureka
 
PHP to Python with No Regrets
PHP to Python with No RegretsPHP to Python with No Regrets
PHP to Python with No Regrets
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
 
Why I Love Python V2
Why I Love Python V2Why I Love Python V2
Why I Love Python V2
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python presentation
Python presentationPython presentation
Python presentation
 
The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.2 book - Part 77 of 84The Ring programming language version 1.2 book - Part 77 of 84
The Ring programming language version 1.2 book - Part 77 of 84
 
Java And Community Support
Java And Community SupportJava And Community Support
Java And Community Support
 
ICDM 2019 Tutorial: Speech and Language Processing: New Tools and Applications
ICDM 2019 Tutorial: Speech and Language Processing: New Tools and ApplicationsICDM 2019 Tutorial: Speech and Language Processing: New Tools and Applications
ICDM 2019 Tutorial: Speech and Language Processing: New Tools and Applications
 
Python an-intro v2
Python an-intro v2Python an-intro v2
Python an-intro v2
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem
 
Invasion of the dynamic language weenies
Invasion of the dynamic language weeniesInvasion of the dynamic language weenies
Invasion of the dynamic language weenies
 
Can Python Overthrow Java? | Java vs Python | Edureka
Can Python Overthrow Java? | Java vs Python | EdurekaCan Python Overthrow Java? | Java vs Python | Edureka
Can Python Overthrow Java? | Java vs Python | Edureka
 
The Ring programming language version 1.7 book - Part 89 of 196
The Ring programming language version 1.7 book - Part 89 of 196The Ring programming language version 1.7 book - Part 89 of 196
The Ring programming language version 1.7 book - Part 89 of 196
 
Python an-intro youtube-livestream-day1
Python an-intro youtube-livestream-day1Python an-intro youtube-livestream-day1
Python an-intro youtube-livestream-day1
 

Semelhante a Python overview

Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.pptRehnawilson1
 
The Ring programming language version 1.10 book - Part 99 of 212
The Ring programming language version 1.10 book - Part 99 of 212The Ring programming language version 1.10 book - Part 99 of 212
The Ring programming language version 1.10 book - Part 99 of 212Mahmoud Samir Fayed
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxManohar k
 
An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()Blue Elephant Consulting
 
The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88Mahmoud Samir Fayed
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxlemonchoos
 
Better problem solving through scripting: How to think through your #eprdctn ...
Better problem solving through scripting: How to think through your #eprdctn ...Better problem solving through scripting: How to think through your #eprdctn ...
Better problem solving through scripting: How to think through your #eprdctn ...BookNet Canada
 
Introduction-to-Python.pptx
Introduction-to-Python.pptxIntroduction-to-Python.pptx
Introduction-to-Python.pptxAyushDey1
 
Pythonlearn-01-Intro.pptx
Pythonlearn-01-Intro.pptxPythonlearn-01-Intro.pptx
Pythonlearn-01-Intro.pptxMrHackerxD
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-introIshaq Ali
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptxArpittripathi45
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptxHaythamBarakeh1
 
Creating a compiler for your own language
Creating a compiler for your own languageCreating a compiler for your own language
Creating a compiler for your own languageAndrea Tino
 

Semelhante a Python overview (20)

Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
 
The Ring programming language version 1.10 book - Part 99 of 212
The Ring programming language version 1.10 book - Part 99 of 212The Ring programming language version 1.10 book - Part 99 of 212
The Ring programming language version 1.10 book - Part 99 of 212
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
 
An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()
 
The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88The Ring programming language version 1.3 book - Part 81 of 88
The Ring programming language version 1.3 book - Part 81 of 88
 
Python basics
Python basicsPython basics
Python basics
 
Python_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptxPython_Introduction_Good_PPT.pptx
Python_Introduction_Good_PPT.pptx
 
Better problem solving through scripting: How to think through your #eprdctn ...
Better problem solving through scripting: How to think through your #eprdctn ...Better problem solving through scripting: How to think through your #eprdctn ...
Better problem solving through scripting: How to think through your #eprdctn ...
 
Introduction-to-Python.pptx
Introduction-to-Python.pptxIntroduction-to-Python.pptx
Introduction-to-Python.pptx
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
 
Pythonlearn-01-Intro.pptx
Pythonlearn-01-Intro.pptxPythonlearn-01-Intro.pptx
Pythonlearn-01-Intro.pptx
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
python-ppt.ppt
python-ppt.pptpython-ppt.ppt
python-ppt.ppt
 
Py4 inf 01-intro
Py4 inf 01-introPy4 inf 01-intro
Py4 inf 01-intro
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
python presntation 2.pptx
python presntation 2.pptxpython presntation 2.pptx
python presntation 2.pptx
 
Python_Introduction&DataType.pptx
Python_Introduction&DataType.pptxPython_Introduction&DataType.pptx
Python_Introduction&DataType.pptx
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
Creating a compiler for your own language
Creating a compiler for your own languageCreating a compiler for your own language
Creating a compiler for your own language
 

Último

Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling ManjurJual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjurptikerjasaptiker
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...nirzagarg
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格q6pzkpark
 
SR-101-01012024-EN.docx Federal Constitution of the Swiss Confederation
SR-101-01012024-EN.docx  Federal Constitution  of the Swiss ConfederationSR-101-01012024-EN.docx  Federal Constitution  of the Swiss Confederation
SR-101-01012024-EN.docx Federal Constitution of the Swiss ConfederationEfruzAsilolu
 
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制vexqp
 
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制vexqp
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Klinik kandungan
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangeThinkInnovation
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...nirzagarg
 
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制vexqp
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...gajnagarg
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowgargpaaro
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...gajnagarg
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样wsppdmt
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATIONLakpaYanziSherpa
 
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制vexqp
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRajesh Mondal
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 

Último (20)

Cytotec in Jeddah+966572737505) get unwanted pregnancy kit Riyadh
Cytotec in Jeddah+966572737505) get unwanted pregnancy kit RiyadhCytotec in Jeddah+966572737505) get unwanted pregnancy kit Riyadh
Cytotec in Jeddah+966572737505) get unwanted pregnancy kit Riyadh
 
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling ManjurJual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
 
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
 
SR-101-01012024-EN.docx Federal Constitution of the Swiss Confederation
SR-101-01012024-EN.docx  Federal Constitution  of the Swiss ConfederationSR-101-01012024-EN.docx  Federal Constitution  of the Swiss Confederation
SR-101-01012024-EN.docx Federal Constitution of the Swiss Confederation
 
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
 
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
怎样办理伦敦大学城市学院毕业证(CITY毕业证书)成绩单学校原版复制
 
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In bhavnagar [ 7014168258 ] Call Me For Genuine Models...
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
 
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 

Python overview

  • 2. What Is Python? What Is Python?  Created in 1990 by Guido van Rossum Created in 1990 by Guido van Rossum  About the origin of Python, Van Rossum wrote in 1996: About the origin of Python, Van Rossum wrote in 1996:  Over six years ago, in December 1989, I was looking for a Over six years ago, in December 1989, I was looking for a "hobby" programming project that would keep me occupied "hobby" programming project that would keep me occupied during the week around Christmas. My office … would be during the week around Christmas. My office … would be closed, but I had a home computer, and not much else on my closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of language I had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus). mood (and a big fan of Monty Python's Flying Circus). 
  • 3. Is Python A Scripting Language? Is Python A Scripting Language?  Usually thought of as one Usually thought of as one  But this is mainly a marketing issue But this is mainly a marketing issue  People think of scripting languages as being People think of scripting languages as being easy to learn, and useful. easy to learn, and useful.  But Python is a well worked out coherent But Python is a well worked out coherent dynamic programming language dynamic programming language  And there is no reason not to use it for a wide And there is no reason not to use it for a wide range of applications. range of applications.
  • 4. Design Philosophy Design Philosophy >>> import this >>> import this The Zen of Python, by Tim Peters The Zen of Python, by Tim Peters Beautiful is better than ugly. Beautiful is better than ugly. Explicit is better than implicit. Explicit is better than implicit. Simple is better than complex. Simple is better than complex. Complex is better than complicated. Complex is better than complicated. Flat is better than nested. Flat is better than nested. Sparse is better than dense. Sparse is better than dense. Readability counts. Readability counts. Special cases aren't special enough to break the rules. Special cases aren't special enough to break the rules. Although practicality beats purity. Although practicality beats purity. Errors should never pass silently. Errors should never pass silently. Unless explicitly silenced. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Now is better than never. Although never is often better than *right* now. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those! Namespaces are one honking great idea -- let's do more of those!
  • 5. Why Python? Why Python?  Designed to be easy to learn and master Designed to be easy to learn and master  Clean, clear syntax Clean, clear syntax  Very few keywords Very few keywords  Highly portable Highly portable  Runs almost anywhere - high end servers and Runs almost anywhere - high end servers and workstations, down to windows CE workstations, down to windows CE  Uses machine independent byte-codes Uses machine independent byte-codes  Extensible Extensible  Designed to be extensible using C/C++, allowing Designed to be extensible using C/C++, allowing access to many external libraries access to many external libraries
  • 6. Most obvious and notorious Most obvious and notorious features features  Clean syntax plus high-level data types Clean syntax plus high-level data types  Leads to fast coding (First language in many Leads to fast coding (First language in many universities abroad!) universities abroad!)  Uses white-space to delimit blocks Uses white-space to delimit blocks  Humans generally do, so why not the Humans generally do, so why not the language? language?  Try it, you will end up liking it Try it, you will end up liking it  Variables do not need declaration Variables do not need declaration  Although not a type-less language Although not a type-less language
  • 7. Productivity! Productivity!  Reduced development time Reduced development time  code is 2-10x shorter than C, C++, Java code is 2-10x shorter than C, C++, Java  Improved program maintenance Improved program maintenance  code is extremely readable code is extremely readable  Less training Less training  language is very easy to learn language is very easy to learn
  • 8. What is it used for? What is it used for?  rapid prototyping rapid prototyping  web scripting web scripting  throw-away, ad hoc programming throw-away, ad hoc programming  steering scientific applications steering scientific applications  extension language extension language  XML processing XML processing  database applications database applications  GUI applications GUI applications  A Glue Language A Glue Language
  • 10. Python vs. Perl Python vs. Perl  Easier to learn Easier to learn  important for occasional users important for occasional users  More readable code More readable code  improved code maintenance improved code maintenance  Fewer “magical” side effects Fewer “magical” side effects  More “safety” guarantees More “safety” guarantees  Better Java integration Better Java integration  Less Unix bias Less Unix bias
  • 11. Python vs. Tcl Python vs. Tcl  Real datatypes, object-orientation Real datatypes, object-orientation  More differentiated syntax More differentiated syntax  Much faster (even than Tcl 8.x) Much faster (even than Tcl 8.x)  Less need for C extensions Less need for C extensions  C extensions don’t redefine syntax C extensions don’t redefine syntax  hence fewer extension conflicts hence fewer extension conflicts  Better Java integration Better Java integration  Python uses Tk as de-facto GUI std Python uses Tk as de-facto GUI std
  • 12. Python vs. Java Python vs. Java  Code 5-10 times more concise Code 5-10 times more concise  Dynamic typing Dynamic typing  Much quicker development Much quicker development  no compilation phase no compilation phase  less typing less typing  Yes, it runs slower Yes, it runs slower  but development is so much faster! but development is so much faster!  Use Python with Java: Jython! Use Python with Java: Jython!
  • 14. Python Programs Python Programs  Python programs and modules are written Python programs and modules are written as text files with traditionally a as text files with traditionally a .py .py extension extension  Each Python module has its own discrete Each Python module has its own discrete namespace namespace  Name space within a Python module is a Name space within a Python module is a global one. global one.
  • 15. Python Programs Python Programs  Python modules and programs are Python modules and programs are differentiated only by the way they are differentiated only by the way they are called called  .py files executed directly are programs (often .py files executed directly are programs (often referred to as scripts) referred to as scripts)  .py files referenced via the .py files referenced via the import import statement statement are modules are modules
  • 16. Python Programs Python Programs  Thus, the same .py file can be a Thus, the same .py file can be a program/script, or a module program/script, or a module  This feature is often used to provide This feature is often used to provide regression tests for modules regression tests for modules  When module is executed as a program, the When module is executed as a program, the regression test is executed regression test is executed  When module is imported, test functionality is When module is imported, test functionality is not executed not executed
  • 17. Variables and Types Variables and Types (1 of 3) (1 of 3)  Variables need no declaration Variables need no declaration  >>> a=1 >>> a=1 >>> >>>  As a variable assignment is a statement, As a variable assignment is a statement, there is no printed result there is no printed result  >>> a >>> a 1 1  Variable name alone is an expression, so Variable name alone is an expression, so the result is printed the result is printed
  • 18. Variables and Types Variables and Types (2 of 3) (2 of 3)  Variables must be created before they can Variables must be created before they can be used be used  >>> b >>> b Traceback (innermost last): Traceback (innermost last): File "<interactive input>", line File "<interactive input>", line 1, in ? 1, in ? NameError: b NameError: b >>> >>>  Python uses exceptions - more detail later Python uses exceptions - more detail later
  • 19. Variables and Types Variables and Types (3 of 3) (3 of 3)  Objects always have a type Objects always have a type  >>> a = 1 >>> a = 1 >>> type(a) >>> type(a) <type 'int'> <type 'int'> >>> a = "Hello" >>> a = "Hello" >>> type(a) >>> type(a) <type 'string'> <type 'string'> >>> type(1.0) >>> type(1.0) <type 'float'> <type 'float'>
  • 20. Assignment versus Equality Assignment versus Equality Testing Testing  Assignment performed with single = Assignment performed with single =  Equality testing done with double = (==) Equality testing done with double = (==)  Sensible type promotions are defined Sensible type promotions are defined  Identity tested with Identity tested with is is operator. operator.  >>> 1==1 >>> 1==1 1 1 >>> 1.0==1 >>> 1.0==1 1 1 >>> "1"==1 >>> "1"==1 0 0
  • 21. Simple Data Types Simple Data Types  Strings Strings  May hold any data, including embedded May hold any data, including embedded NULLs NULLs  Declared using either single, double, or triple Declared using either single, double, or triple quotes quotes  >>> s = "Hi there" >>> s = "Hi there" >>> s >>> s 'Hi there' 'Hi there' >>> s = "Embedded 'quote'" >>> s = "Embedded 'quote'" >>> s >>> s "Embedded 'quote'" "Embedded 'quote'"
  • 22. Simple Data Types Simple Data Types  Triple quotes useful for multi-line strings Triple quotes useful for multi-line strings  >>> s = """ a long >>> s = """ a long ... string with "quotes" or ... string with "quotes" or anything else""" anything else""" >>> s >>> s ' a long012string with "quotes" or ' a long012string with "quotes" or anything else' anything else' >>> len(s) >>> len(s) 45 45
  • 23. Simple Data Types Simple Data Types  Integer objects implemented using C Integer objects implemented using C longs longs  Like C, integer division returns the floor Like C, integer division returns the floor  >>> 5/2 >>> 5/2 2 2  Float types implemented using C doubles Float types implemented using C doubles  No point in having single precision since No point in having single precision since execution overhead is large anyway execution overhead is large anyway
  • 24. Simple Data Types Simple Data Types  Long Integers have unlimited size Long Integers have unlimited size  Limited only by available memory Limited only by available memory  >>> long = 1L << 64 >>> long = 1L << 64 >>> long ** 5 >>> long ** 5 21359870359209100823950217061695521146027045223 21359870359209100823950217061695521146027045223 56652769947041607822219725780640550022962086936 56652769947041607822219725780640550022962086936 576L 576L
  • 25. High Level Data Types High Level Data Types  Lists hold a sequence of items Lists hold a sequence of items  May hold any object May hold any object  Declared using square brackets Declared using square brackets  >>> l = []# An empty list >>> l = []# An empty list >>> l.append(1) >>> l.append(1) >>> l.append("Hi there") >>> l.append("Hi there") >>> len(l) >>> len(l) 2 2
  • 26. High Level Data Types High Level Data Types  >>> l >>> l [1, 'Hi there'] [1, 'Hi there'] >>> >>> >>> l = ["Hi there", 1, 2] >>> l = ["Hi there", 1, 2] >>> l >>> l ['Hi there', 1, 2] ['Hi there', 1, 2] >>> l.sort() >>> l.sort() >>> l >>> l [1, 2, 'Hi there'] [1, 2, 'Hi there']
  • 27. High Level Data Types High Level Data Types  Tuples are similar to lists Tuples are similar to lists  Sequence of items Sequence of items  Key difference is they are immutable Key difference is they are immutable  Often used in place of simple structures Often used in place of simple structures  Automatic unpacking Automatic unpacking  >>> point = 2,3 >>> point = 2,3 >>> x, y = point >>> x, y = point >>> x >>> x 2 2
  • 28. High Level Data Types High Level Data Types  Tuples are particularly useful to return Tuples are particularly useful to return multiple values from a function multiple values from a function  >>> x, y = GetPoint() >>> x, y = GetPoint()  As Python has no concept of byref As Python has no concept of byref parameters, this technique is used widely parameters, this technique is used widely
  • 29. High Level Data Types High Level Data Types  Dictionaries hold key-value pairs Dictionaries hold key-value pairs  Often called maps or hashes. Implemented Often called maps or hashes. Implemented using hash-tables using hash-tables  Keys may be any immutable object, values Keys may be any immutable object, values may be any object may be any object  Declared using braces Declared using braces  >>> d={} >>> d={} >>> d[0] = "Hi there" >>> d[0] = "Hi there" >>> d["foo"] = 1 >>> d["foo"] = 1
  • 30. High Level Data Types High Level Data Types  Dictionaries (cont.) Dictionaries (cont.)  >>> len(d) >>> len(d) 2 2 >>> d[0] >>> d[0] 'Hi there' 'Hi there' >>> d = {0 : "Hi there", 1 : >>> d = {0 : "Hi there", 1 : "Hello"} "Hello"} >>> len(d) >>> len(d) 2 2
  • 31. Blocks Blocks  Blocks are delimited by indentation Blocks are delimited by indentation  Colon used to start a block Colon used to start a block  Tabs or spaces may be used Tabs or spaces may be used  Maxing tabs and spaces works, but is Maxing tabs and spaces works, but is discouraged discouraged  >>> if 1: >>> if 1: ... ... print "True" print "True" ... ... True True >>> >>>
  • 32. Blocks Blocks  Many hate this when they first see it Many hate this when they first see it  Most Python programmers come to love it Most Python programmers come to love it  Humans use indentation when reading Humans use indentation when reading code to determine block structure code to determine block structure  Ever been bitten by the C code?: Ever been bitten by the C code?:  if (1) if (1) printf("True"); printf("True"); CallSomething(); CallSomething();
  • 33. Looping Looping  The The for for statement loops over sequences statement loops over sequences  >>> for ch in "Hello": >>> for ch in "Hello": ... ... print ch print ch ... ... H H e e l l l l o o >>> >>>
  • 34. Looping Looping  Built-in function Built-in function range() range() used to build used to build sequences of integers sequences of integers  >>> for i in range(3): >>> for i in range(3): ... print i ... print i ... ... 0 0 1 1 2 2 >>> >>>
  • 35. Looping Looping  while while statement for more traditional statement for more traditional loops loops  >>> i = 0 >>> i = 0 >>> while i < 2: >>> while i < 2: ... print i ... print i ... i = i + 1 ... i = i + 1 ... ... 0 0 1 1 >>> >>>
  • 36. Functions Functions  Functions are defined with the Functions are defined with the def def statement: statement:  >>> def foo(bar): >>> def foo(bar): ... return bar ... return bar >>> >>>  This defines a trivial function named This defines a trivial function named foo foo that takes a single parameter that takes a single parameter bar bar
  • 37. Functions Functions  A function definition simply places a A function definition simply places a function object in the namespace function object in the namespace  >>> foo >>> foo <function foo at fac680> <function foo at fac680> >>> >>>  And the function object can obviously be And the function object can obviously be called: called:  >>> foo(3) >>> foo(3) 3 3 >>> >>>
  • 38. Classes Classes  Classes are defined using the Classes are defined using the class class statement statement  >>> class Foo: >>> class Foo: ... def __init__(self): ... def __init__(self): ... self.member = 1 ... self.member = 1 ... def GetMember(self): ... def GetMember(self): ... return self.member ... return self.member ... ... >>> >>>
  • 39. Classes Classes  A few things are worth pointing out in the A few things are worth pointing out in the previous example: previous example:  The constructor has a special name The constructor has a special name __init__ __init__, while a destructor (not shown) , while a destructor (not shown) uses uses __del__ __del__  The The self self parameter is the instance (ie, the parameter is the instance (ie, the this this in C++). In Python, the self parameter in C++). In Python, the self parameter is explicit (c.f. C++, where it is implicit) is explicit (c.f. C++, where it is implicit)  The name The name self self is not required - simply a is not required - simply a convention convention
  • 40. Classes Classes  Like functions, a class statement simply Like functions, a class statement simply adds a class object to the namespace adds a class object to the namespace  >>> Foo >>> Foo <class __main__.Foo at 1000960> <class __main__.Foo at 1000960> >>> >>>  Classes are instantiated using call syntax Classes are instantiated using call syntax  >>> f=Foo() >>> f=Foo() >>> f.GetMember() >>> f.GetMember() 1 1
  • 41. Modules Modules  Most of Python’s power comes from Most of Python’s power comes from modules modules  Modules can be implemented either in Modules can be implemented either in Python, or in C/C++ Python, or in C/C++  import import statement makes a module statement makes a module available available  >>> import string >>> import string >>> string.join( ["Hi", "there"] ) >>> string.join( ["Hi", "there"] ) 'Hi there' 'Hi there' >>> >>>
  • 42. Exceptions Exceptions  Python uses exceptions for errors Python uses exceptions for errors  try try / / except except block can handle exceptions block can handle exceptions  >>> try: >>> try: ... 1/0 ... 1/0 ... except ZeroDivisionError: ... except ZeroDivisionError: ... print "Eeek" ... print "Eeek" ... ... Eeek Eeek >>> >>>
  • 43. Exceptions Exceptions  try try / / finally finally block can guarantee block can guarantee execute of code even in the face of execute of code even in the face of exceptions exceptions  >>> try: >>> try: ... 1/0 ... 1/0 ... finally: ... finally: ... print "Doing this anyway" ... print "Doing this anyway" ... ... Doing this anyway Doing this anyway Traceback (innermost last): File "<interactive Traceback (innermost last): File "<interactive input>", line 2, in ? input>", line 2, in ? ZeroDivisionError: integer division or modulo ZeroDivisionError: integer division or modulo >>> >>>
  • 44. Threads Threads  Number of ways to implement threads Number of ways to implement threads  Highest level interface modelled after Highest level interface modelled after Java Java  >>> class DemoThread(threading.Thread): >>> class DemoThread(threading.Thread): ... def run(self): ... def run(self): ... for i in range(3): ... for i in range(3): ... time.sleep(3) ... time.sleep(3) ... print i ... print i ... ... >>> t = DemoThread() >>> t = DemoThread() >>> t.start() >>> t.start() >>> t.join() >>> t.join() 0 0 1 1 <etc> <etc>
  • 45. Standard Library Standard Library  Python comes standard with a set of modules, Python comes standard with a set of modules, known as the “standard library” known as the “standard library”  Incredibly rich and diverse functionality available Incredibly rich and diverse functionality available from the standard library from the standard library  All common internet protocols, sockets, CGI, OS All common internet protocols, sockets, CGI, OS services, GUI services (via Tcl/Tk), database, services, GUI services (via Tcl/Tk), database, Berkeley style databases, calendar, Python Berkeley style databases, calendar, Python parser, file globbing/searching, debugger, parser, file globbing/searching, debugger, profiler, threading and synchronisation, profiler, threading and synchronisation, persistency, etc persistency, etc
  • 46. External library External library  Many modules are available externally Many modules are available externally covering almost every piece of covering almost every piece of functionality you could ever desire functionality you could ever desire  Imaging, numerical analysis, OS specific Imaging, numerical analysis, OS specific functionality, SQL databases, Fortran functionality, SQL databases, Fortran interfaces, XML, Corba, COM, Win32 API, interfaces, XML, Corba, COM, Win32 API, comedilib, serial, parallel, opengl, opencv, comedilib, serial, parallel, opengl, opencv, wxpython, gtk, qt, tkinter etc wxpython, gtk, qt, tkinter etc  Way too many to give the list any justice Way too many to give the list any justice
  • 47. More Information on Python More Information on Python  Comes with extensive documentation, Comes with extensive documentation, including tutorials and library reference including tutorials and library reference  Also a number of Python books available Also a number of Python books available  Visit Visit www.python.org www.python.org for more details for more details  Can find python tutorial and reference manual Can find python tutorial and reference manual