20061216 python intro
Upcoming SlideShare
Loading in...5
×
 

20061216 python intro

on

  • 2,453 views

 

Statistics

Views

Total Views
2,453
Views on SlideShare
2,451
Embed Views
2

Actions

Likes
0
Downloads
68
Comments
0

1 Embed 2

http://www.slideshare.net 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

20061216 python intro 20061216 python intro Presentation Transcript

  • Python, A Charming Language Python, A Charming Language hzmangel@bupt Multimedia Technology Teaching and Researching Center BUPT December 13, 2006
  • Python, A Charming Language Contents 1 A Brief Intro to Python 2 Application Domains 3 Playing with Others 4 To be Pythonic 5 Some Demos 6 Networks Resources
  • Python, A Charming Language A Brief Intro to Python The Definitions Two Definitions Python is one of those rare languages which can claim to be both simple and powerful. You will find it easy to concentrate on the solution to your problem rather than having to concentrate on the programming language. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
  • Python, A Charming Language A Brief Intro to Python The History The History for Python Guido van Rossum, the creator of the Python language. Xmas day in 1989. BBC show “Monty Python’s Flying Circus”
  • Python, A Charming Language A Brief Intro to Python Features Features of Python I Simple: Python is a simple and minimalistic language. Reading a good Python program feels almost like reading English, although very strict English. This pseudo-code nature of Python is one of its greatest strengths. Easy to Learn: Python is extremely easy to get started with, it has an extraordinarily simple syntax. Free and Open Source: Python is an example of a FOSS(Free and Open Source Software).
  • Python, A Charming Language A Brief Intro to Python Features Features of Python II High-level Language: When you write programs in Python, you do not have to worry about low-level details such as managing the memory used by your program, etc. Protable: Python has been ported to many platforms, All your Python programs can work on most of these platforms without requiring any changes at all, if you are careful enough to avoid any system-specific features. Interpreted: Python does not need compilation to a binary. It converts the source code to a bytecodes file.
  • Python, A Charming Language A Brief Intro to Python Features Features of Python III Object-oriented: Python supports procedure-oriented programming as well as object-oriented programming. Extensible: Python can use the code written in C/C++. Embeddable: You can embed Python within your C/C++ programs to give ’scripting’ capabilities for your program’s users. Extensive Libraries: The Python Standard Library is huge, and there are a huge number of high-quality libraries available for Python.
  • Python, A Charming Language Application Domains Many Application Domains GUI, network Graphic and image process Document process Game development Website Scientific computing ...
  • Python, A Charming Language Application Domains GUI Libraries GUI Libraries Tcl/tk wxPython PyGTK PyQT PySWT
  • Python, A Charming Language Application Domains Network Development Network Development socket module High-level network module SocketServer, BaseHTTPServer, CGIHTTPServer, ... email, ftplib, telnetlib, ... twisted jabber library Python-QQ
  • Python, A Charming Language Application Domains Graphics and Images Graphics and Images PIL: Python Imaging Library PyOpenGL Blender matplotlib yapgvb
  • Python, A Charming Language Application Domains Document Process Document Process epydoc ReportLab
  • Python, A Charming Language Application Domains Game Development Game Development pygame
  • Python, A Charming Language Application Domains Web Development Web Development mod python + Apache zope/plone karrigell cherrypy django
  • Python, A Charming Language Application Domains Scientific Computing Scientific Computing numarray numeric
  • Python, A Charming Language Playing with Others Playing with Others COM Python for Windows extensions .NET IronPython, Python for .NET Java Jython
  • Python, A Charming Language To be Pythonic Zen of Python Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren’t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. 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. Now is better than never. Although never is often better than *right* now. 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. Namespaces are one honking great idea -- let’s do more of those! -- by Tim Peters
  • Python, A Charming Language Some Demos Some Demos The slides followed will show some demos. Almost all of them are copy from the turtiol
  • Python, A Charming Language Some Demos GUI Development wxPython: Python + wxWidgets import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) class MyApp(wx.App): def OnInit(self): frame = MyFrame(None, -1, "This is a test") frame.Show(True) self.SetTopWindow(frame) return True def main(): app = MyApp(0) app.MainLoop() if __name__ == "__main__": main()
  • Python, A Charming Language Some Demos GUI Development Screenshot Figure: A simplewxPython app
  • Python, A Charming Language Some Demos GUI Development BOA Constructor Wiritten in Python A Python IDE and wxPython GUI Builder http://boa-constructor.sourceforge.net
  • Python, A Charming Language Some Demos GUI Development Some Screenshots of BOA I Figure: Frame Design
  • Python, A Charming Language Some Demos GUI Development Some Screenshots of BOA II Figure: Source Edit
  • Python, A Charming Language Some Demos GUI Development Some Screenshots of BOA III Figure: Debugger
  • Python, A Charming Language Some Demos GUI Development Some Screenshots of BOA IV Figure: UML View
  • Python, A Charming Language Some Demos Image Process PIL: Python Image Library Support many file format. Provide powerful image processing and graphics capabilities. Include filter, enchancement, ... Export PostScript file.
  • Python, A Charming Language Some Demos Image Process Demo Code import Image import ImageFilter import ImageEnchance im = Image.open("lenna.jpg") im_rotate = im.rotate(45) im_resize = im.resize(128, 128) im_crop = im.crop((0, 0, 256, 256)) im_trans = im.transpose(Image.FLIP_LEFT_RIGHT) r,g,b = im.split() im_edge = im.filter(ImageFilter.FIND_EDGES) im_enh = ImageEnhance.Contrast(im) enh.enhance(1.3).show().
  • Python, A Charming Language Some Demos Image Process Some Results
  • Python, A Charming Language Some Demos Scientific Computing SciPy: Scientific Tools for Python Pronounced Sigh Pie Core library is NumPy Provides many user-friendly and efficient numerical routines http://www.scipy.org
  • Python, A Charming Language Some Demos Scientific Computing A Simple Program from enthought.chaco.wx import plt from scipy import arange, optimize, special plt.figure() plt.hold() w = [] z = [] x = arange(0,10,.01) for k in arange(1,5,.5): y = special.jv(k,x) plt.plot(x,y) f = lambda x: -special.jv(k,x) x_max = optimize.fminbound(f,0,6) w.append(x_max) z.append(special.jv(k,x_max)) plt.plot(w,z, ’ro’) from scipy import interpolate t = interpolate.splrep(w, z, k=3) s_fit3 = interpolate.splev(x,t) plt.plot(x,s_fit3, ’g-’) t5 = interpolate.splrep(w, z, k=5) s_fit5 = interpolate.splev(x,t5) plt.plot(x,s_fit5, ’y-’)
  • Python, A Charming Language Some Demos Scientific Computing The Result Figure: Result of SciPy Demo
  • Python, A Charming Language Some Demos Game Demo PyGame A set of Python modules Designed for writing games Written on top of SDL library
  • Python, A Charming Language Networks Resources Forums and Groups Forums and Groups http://www.python.org http://python.cn http://www.woodpecker.org.cn http://groups.google.com/group/python-cn
  • Python, A Charming Language Networks Resources Python Powered Websites Websites Powered by Python http://moinmoin.wikiwikiweb.de http://www.douban.com
  • Python, A Charming Language Networks Resources Python Powered Websites Q&A Q&A
  • Python, A Charming Language Networks Resources Python Powered Websites Thanks Thanks