Upload
tsungwei-hu
View
832
Download
5
Embed Size (px)
DESCRIPTION
Python Introduction in the Group Meeting on 2012/10/30.
Citation preview
Copyright © Elitegroup Computer Systems. All Rights Reserved Page1
組內報告
Python for Application Integration and Development
胡崇偉 marr
2012/10/30
Python
for Application
Integration and Development
組內報告 2012/10/30 2
Agenda
History of Python
Python Features
Python as Research Workbench
Python for Web Development
Python Community
Conclusion
組內報告 2012/10/30 3
In the 70s,
Xerox PARC asked:
Can we have a computer on every desk?
組內報告 2012/10/30 4
A follow-up Question:
What will happen if users can
program their own computer?
組內報告 2012/10/30 5
History of Python
Guido van Rossum created Python when he was working at CWI (Centrum Wiskunde & Informatica) during 1989 - 1991
組內報告 2012/10/30 6
Python Chronology
1989
1995
2001
2004
CP4E
1994
Programming as a Literacy
Research
CWI
comp.lang.python
CNRI
2009
Education
Commercial
組內報告 2012/10/30 7
The Year When My Script Looks Like…
use CGI;
my $q = CGI->new();
say $q->header(), $q->start_html();
say "<h1>Parameters</h1>";
for my $param ($q->param()) {
my $safe_param = $q->escapeHTML($param);
say "<p><strong>$safe_param</strong>: ";
for my $value ($q->param($param)) {
say $q->escapeHTML($value);
}
say '</p>';
}
say $q->end_html();
組內報告 2012/10/30 8
My Brain Just Hardly Fits Them…
Even Worse…
my $q%&*#@->{~(,)};
inconsistent coding style?
組內報告 2012/10/30 9
Python Features: Easy to Learn
if ’smiths’ in RegisterList:
sendNote(‘VIP registered’)
elif ’doe’ not in RegisterList:
startPlan(‘B’)
else:
print len(RegisterList)
length() will return # of elements
組內報告 2012/10/30 10
Python Features: Indentation
if ’smiths’ in RegisterList:
sendNote(‘VIP registered’)
elif ’doe’ not in RegisterList:
startPlan(‘B’)
else:
print(len(RegisterList))
Indentation with white spaces
組內報告 2012/10/30 11
Readability counts
Programs are meant to be read by humans and only incidentally for computersto execute -- Donald Knuth
組內報告 2012/10/30 12
The Zen of Python, by Tim Peters
There should be one –and preferably only one –obvious way to do it.
• Having one way to do it is an advantage.
Once the idioms are hardwired in your brain,
you’d have instant recognition.
Toward Pythonic Thinking
組內報告 2012/10/30 13
Python as Research Workbench
Python makes it easy to balance high-level
programming with low-level optimization.
Python excels at gluing other languages.
Numerous libraries provide the needed
functionality for scientific.
Python incorporates documentation and
testing directly into the language itself.
組內報告 2012/10/30 14
reStructuredText Example
.. math:: \Gamma(z) =\int_0^\infty x^{z-1}e^{-x}\,dx
組內報告 2012/10/30 15
Research Libraries
Fortran to Python
interface generator
ctypes
組內報告 2012/10/30 16
GIS and SQL Tools
ArcPy
PyPROJgeopy
Shapely
Fiona
組內報告 2012/10/30 17
Python for Web Development
Common Ways to Have Your Web Sites:
• Building Them with Frameworks• Building Them with CMSes
You
are
here
Your
Website
here
組內報告 2012/10/30 18
Plone, a Python based CMS
CMS = Contents Stored in DatabaseAdded/Edited by User/GroupManaged with WorkflowSearchable via Index/Catalog
Forms in Database
or simply…
組內報告 2012/10/30 19
Form Elements
CMS = Contents Stored in DatabaseAdded/Edited by User/GroupManaged with WorkflowSearchable via Index/Catalog
組內報告 2012/10/30 20
Dexterity Content Types
組內報告 2012/10/30 21
Form Behaviors
CMS = Contents Stored in DatabaseAdded/Edited by User/GroupManaged with WorkflowSearchable via Index/Catalog
組內報告 2012/10/30 22
Form Behaviors: Maps Enabled
組內報告 2012/10/30 23
More Packages Needed? Python Packages are distributed as Eggs and
listed on http://pypi.python.org/
組內報告 2012/10/30 24
Python Community
組內報告 2012/10/30 25
The Python Paradox, by Paul Graham
• You could get smarter programmers to work
on a Python project than you could to work
on a Java project.
• If a company chooses to write its software in
a comparatively esoteric language, they'll be
able to hire better programmers, because
they'll attract only those who cared enough
to learn it.
• The language to learn, if you want to get a
good job, is a language that people don't
learn merely to get a job.
組內報告 2012/10/30 26
Conclusion
Python serves well as the first language to
learn, even better as the glue when
working with other languages or tools.
It helps to improve team productivity.
Get more: Extending with C/C++ or
Embedding in Applications
Google Engineering Decision:
Python where we can, C++ where we must
組內報告
Python Style Ending
if questions:
try:
answer()
except RuntimeError:
pass
else:
print(‘Thank You.’)