Upload
maher-gamal
View
608
Download
3
Tags:
Embed Size (px)
DESCRIPTION
An introductory session that given during the Cairo GTUG Meeting #4.
Citation preview
A Sip of Python in 30 mins.
Maher Gamal
Cairo-GTUG
Development Cultures
SAFE
• Follows the big companies
• Must be widely approved
• No chance for risks
EXPLORATORY
• Tries out young technologies
• Mostly self-motivated
• Accepts calculated risks
How does Python look like ?
>>> print("Welcome everyone !")Welcome everyone !
>>> print("Welcome to %s !" % "GTUG")Welcome to GTUG !
>>> print("%s live in %s !" % ("GTUG", "Cairo"))GTUG live in Cairo !
# Enough with the print statements !# What's next ? Modules !
How does Python look like ?
>>> import os
>>> os.listdir("/home/maherg")['Documents', 'Pictures', 'Workspaces']
>>> import sys
>>> sys.modules.keys()[ ... 'os', 'time', 'subprocess', ... ]
# Can we write our own module ? Yes, we can !
How does Python look like ?
# gtug.py: GTUG's schedule
print("Welcome to GTUG's schedule !")
sessions = ['Python', 'AppEngine', 'Hands-on Practice']def list_sessions(): """Prints the sessions for today""" print("Sessions List:") for s in sessions: print("- %s" % s)
How does Python look like ?
>>> os.listdir(".")['gtug.py']
>>> import gtugWelcome to GTUG's schedule !
>>> gtug.list_sessions()Sessions List:- Python- AppEngine- Hands-on Practice
How does Python look like ?
# gtug.py: GTUG's schedule
print("Welcome to GTUG's schedule !")
sessions = {'Python' : 'Maher Gamal', 'AppEngine' : 'Amahdy Abdelaziz', 'Hands-on Practice' : 'Everyone'}def list_sessions(): """Prints the sessions for today""" print("Sessions List:") for name, speaker in sessions.items(): print("- %s (%s)" % (name, speaker))
How does Python look like ?
>>> import gtugWelcome to GTUG's schedule !
>>> gtug.list_sessions()Sessions List:- Python (Maher Gamal)- AppEngine (Amahdy Abdelaziz)- Hands-on Practice (Everyone)
>>> # What's next ? Packages !
How does Python look like ?
# gtug/__init__.py : GTUG's Package Indicator
print("Welcome to GTUG !")
# gtug/schedule.py : GTUG's Schedule Module
>>> import gtugWelcome to GTUG !
>>> import gtug.scheduleWelcome to GTUG's schedule !
>>> gtug.schedule.list_sessions()
How does Python look like ?
>>> from gtug import scheduleWelcome to GTUG !Welcome to GTUG's schedule !
>>> schedule.list_sessions()...
>>> from gtug.schedule import list_sessions
>>> list_sessions()...# What's next ? Classes !
How does Python look like ?
# gtug/classes.py : GTUG's classes
class Session(): def __init__(self, title, status = 'none'): self.title = title self.status = status
def start(self): self.status = 'started' def stop(self): self.status = 'stopped'
How does Python look like ?
>>> from gtug.classes import Session>>> s = Session('A Sip of Python')
>>> s.start()...>>> s.stop()
>>> Session(status = 'pending', title = '...').start()
Python's Edges
• Allows multiple paradigms
• Easily readable
• Supports incremental development
• Portable ( Runs on Win/Lin/Mac...etc.)
• Has loads of community-driven libraries
Python meets the Web
from google.appengine.ext import webappfrom webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler): def get(self): self.response.out.write('Main Page')
application = webapp.WSGIApplication([('/', MainPage)])
run_wsgi_app(application)
Python Resources
Stay in Touch
• linkedin : linkedin.com/in/mahergamal
• blog : maherg.blogspot.com
• email : [email protected]
• mobile : 011 351 585 1