python python طراحی و پیاده سازی زبانهای برنامهسازی

21
دا ام خ ه ن ب

Upload: holly-perkins

Post on 26-Dec-2015

243 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

به نام خدا

Page 2: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

محققان:علیرضا اخوان پورسینا پدیدارامیر آهنگی

استاد راهنما: مهندس معزکریمیسرکار خانم

دانشگاه شهید رجایی90مهرماه

Pythonطراحی و پیاده سازی زبان های برنامه سازی

Page 3: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

w w w . p y t h o n . o r g

Python

Page 4: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

What’s in a name?

جالب است بدانید که: آن برنام0ه م0ورد عالقه ی س0ازنده ی از پ0ایتون ن0ام

ب0ود ی0ک برنام0ه ی کم0دی انگلیس0ی ک0ه مون0تی پ0ایتوناس0000000000ت!! ش0000000000ده گرفت0000000000ه

(به هلندی: )توسط خ=ودو فان روسومGuido van Rossum در کشور هلند طراحی شد.۱۹۹۱ در سال

Page 5: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

What is Python?

O-O rapid prototyping languageNot just a scripting languageNot just another PerlEasy to learn, read, useExtensible (add new modules)

◦C/C++/Fortran/whatever◦Java (through Jython)

Embeddable in applications

Page 6: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Touchy-feely properties

متن باز و اپن سورس(OSI Certified)©( , اما استفاده محدود CopyRightدارای کپی رایت)◦

نمی شود◦owned by independent non-profit, PSF

پشتیبان کاربرانفراوانی منابع و کتب آموزشی◦

طراحی ساده, فراگیری آسان”(pseudo-codeخوانایی ساده همچو شبه کد )“◦مناسب به عنوان اولین زبان◦مناسب به عنوان آخرین زبان◦

Page 7: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

High-level properties

( قابلیت قابل حملPortable)◦Unix/Linux, Windows, Mac, PalmOS,

WindowsCE, RiscOS, VxWorks, QNX, OS/2, OS/390, AS/400, PlayStation, Sharp Zaurus,

BeOS, VMS…( کامپایل به کد بایت تفسیرinterpreted byte

code)◦compilation is implicit and automatic

مدیریت خودکار حافظه◦reference counting for most situations◦GC added for cycle detection

“Safe”: no core dumps due to your bugs

Page 8: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

What is it used for?

( نمونه سازی سریعrapid prototyping) ( استفاده در برنامه نویسی وبclient and server

side)(مناسب برای برنامه های علمیsteering scientific

applications)(زبان الحاقیextension language) پردازشXMLdatabase applicationsGUI applicationsآموزش

Page 9: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Who is using it?

Google (various projects)NASA (several projects)NYSE (one of only three languages "on the

floor")Industrial Light & Magic (everything)Yahoo! (Yahoo mail & groups)RealNetworks (function and load testing)RedHat (Linux installation tools)LLNL, Fermilab (steering scientific applications)Zope Corporation (content management)ObjectDomain (embedded Jython in UML tool)Alice project at CMU (accessible 3D graphics)More success stories at www.pythonology.com

Page 10: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Language properties

Everything is an objectPackages, modules, classes, functionsException handlingDynamic typing, polymorphismStatic scopingOperator overloadingIndentation for block structure ( تو رفتگی برای

(ساختار بلوک

◦Otherwise conventional syntax

Page 11: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

High-level data types

Numbers: int, long, float, complexStrings, Unicode: immutableLists and dictionaries: containersOther types for e.g. binary data, regular

expressions, introspectionExtension modules can define new

“built-in” data types

Page 12: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Interfaces to...

XML◦ DOM, expat◦ XMLRPC, SOAP, Web Services

Relational databases◦ MySQL, PostgreSQL, Oracle , ODBC, Sybase, Informix

Java (via Jython)Objective CCOM, DCOM (.NET too)Many GUI libraries

◦ cross-platform Tk, wxWindows, GTK, Qt

◦ platform-specific MFC, Mac (classic, Cocoa), X11

Page 13: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Compared to Perl

Easier to learn◦very important for infrequent users

More readable codeMore maintainable codeFewer “magical” side effectsMore “safety” guaranteesBetter Java integration

Page 14: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Compared to Java

Code up to 5 times shorter◦ and more readable

Dynamic typingMultiple inheritance, operator overloadingQuicker development

◦ no compilation phase◦ less typing

Yes, it may run a bit slower◦ but development is much faster◦ and Python uses less memory (studies show)

Similar (but more so) for C/C++

Page 15: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Jython

Seamless integration with JavaSeparate implementationImplements the same languageDifferent set of standard modulesdifferences in “gray areas”

◦e.g. some different introspection calls◦different command line options, etc.

Page 16: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Example code

زبان پایتون بسیار شبیه به زبان انسان است را که اولین برنامه ساده می باشد را در دو Hello Worldبرنامه

مقایسه کنید :Python و Cزبان

int main(){printf("Hello World ");return 0;}

اما بوسیله پایتون در یک فایل متنی بنویسید

print "Hello World !!"

اونو اجرا کنید . python hi.pyو با دستور

Page 17: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Jython's Java integration

InteractiveCompiles directly to Java bytecodeImport Java classes directlySubclass Java classes

◦pass instances back to JavaJava beans integrationCan compile into Java class files

Page 18: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Example function

def gcd(a, b): "greatest common divisor" while a != 0: a, b = b%a, a # parallel assignment

return b

Page 19: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

Example class

class Stack: "A well-known data structure" # doc string def __init__(self): # constructor self.items = [] def push(self, x): self.items.append(x) # the sky is the limit def pop(self): x = self.items[-1] # what happens if it’s empty? del self.items[-1] return x def empty(self): return len(self.items) == 0

Page 20: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

References and plugs

:منابع◦ www.python.org - Python home site

documentation, downloads, community, PSF◦ www.pythonology.org - success stories◦ www.artima.com/intv - interview with GvR◦ www.zope.org - Zope community site◦ www.zope.com - Zope corporate site

Python Conferences (see www.python.org):◦ PyCon DC March 26-28 Washington, DC

on-line registration ends today ($200)◦ Python UK April 2-3 Oxford, England◦ EuroPython June 25-27 Charleroi, Belgium◦ Python11 at OSCON July 7-11 Portland, OR

Page 21: Python Python طراحی و پیاده سازی زبانهای برنامهسازی

!More information

اطالعات بیشتر در زمینه یGoogle App Engineمنابع مطالعاتی فارسی و انگلیسیاسالید آموزشی به همراه توضیحات تایپ شده

www.AlirezaWeb.com

آموزش فارسی و فروم های پرسش و پاسخwww.barnamenevis.org

www.pylearn.com

سایت رسمی پایتونwww.python.org