4. Python ist eine Programmiersprache, die mehrere
Programmierparadigmen ermöglicht. So werden
objektorientierte, aspektorientierte und funktionale
Programmierung unterstützt.
http://de.wikipedia.org/wiki/Python_(Programmiersprache)
Python im Web: Django - Florian Herlings, 21.10.2009 4/48
5. schwach, dynamisch typisierte
Python ist eine Programmiersprache, die mehrere
Programmierparadigmen ermöglicht. So werden
objektorientierte, aspektorientierte und funktionale
Programmierung unterstützt.
http://de.wikipedia.org/wiki/Python_(Programmiersprache)
Python im Web: Django - Florian Herlings, 21.10.2009 5/48
6. Python ist eine Programmiersprache, die mehrere
Programmierparadigmen ermöglicht. So werden
objektorientierte, aspektorientierte und funktionale
Programmierung unterstützt. Erfunden von einem Holländer
http://de.wikipedia.org/wiki/Python_(Programmiersprache)
Python im Web: Django - Florian Herlings, 21.10.2009 6/48
7. Guido
http://www.flickr.com/photos/47178427@N00/176564536/ Lizenz: CC BY 2.0
Python im Web: Django - Florian Herlings, 21.10.2009 7/48
8. Guido van Rossum
„Vor über sechs Jahren, im Dezember 1989, suchte
ich nach einem Programmierprojekt, das mich über
die Weihnachtswoche beschäftigen würde.
Mein Büro würde geschlossen bleiben, aber ich
hatte auch zu Hause einen PC und sonst nicht viel zu
tun.
Ich entschied mich, einen Interpreter für die
Scriptsprache zu schreiben, über die ich kürzlich
nachdachte: Ein Nachfolger von ABC, der auch Unix-
und C-Hacker ansprechen würde. Ich wählte Python
als Arbeitstitel für das Projekt, weil ich in einer
leicht respektlosen Stimmung (und ein großer Fan
des Monty Python’s Flying Circus) war.“
http://www.flickr.com/photos/docsearls/ Lizenz: CC BY-SA 2.0
Python im Web: Django - Florian Herlings, 21.10.2009 8/48
9. Python im Web: Django - Florian Herlings, 21.10.2009 9/48
10. The 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!
Python im Web: Django - Florian Herlings, 21.10.2009 10/48
11. Python-Syntax
- dynamisch typisierte Skriptsprache
- wenig verbose Syntax (hier Java-Scherz einfügen ;)
- „batteries included“ (sehr große Standard-Library)
- für jedes Problem soll es einen und zwar genau
einen Weg geben es in der Sprache zu lösen
- Alles ist ein Objekt (ja, auch Funktionen!)
- Einrückung statt geschweifter Klammern (WTF?)
Python im Web: Django - Florian Herlings, 21.10.2009 11/48
13. Verschachtelung
if (name == 'Peter'):
print 'Hallo Peter.'
else:
print 'Hallo Du!'
4 Leerzeichen, 2 Leerzeichen oder ein Tab
Python im Web: Django - Florian Herlings, 21.10.2009 13/48
14. Arrays
autos = ['Mercedes', 'BMW', 'Opel']
for auto in autos:
print 'Auto: ' + auto
Ausgabe:
Auto: Mercedes
Auto: BMW
Auto: Opel
Python im Web: Django - Florian Herlings, 21.10.2009 14/48
15. Arrays: list comprehension
autos = ['Mercedes', 'BMW', 'Opel']
kleine_autos = [auto.lower() for auto in autos]
['mercedes', 'bmw', 'opel']
Python im Web: Django - Florian Herlings, 21.10.2009 15/48
16. Arrays: list comprehension
autos = ['Mercedes', 'BMW', 'Opel']
teure_autos = [auto.lower()
for auto in autos
if auto != 'Opel']
['mercedes', 'bmw']
Python im Web: Django - Florian Herlings, 21.10.2009 16/48
18. Funktionen
def sag_hallo(name):
print 'Hallo, wie geht es dir %s?' % name
sag_hallo('Peter')
sag_hallo(name = 'Karl-Heinz')
Ausgabe:
Hallo, wie geht es dir Peter?
Hallo, wie geht es dir Karl-Heinz?
Python im Web: Django - Florian Herlings, 21.10.2009 18/48
19. Klassen
class Auto(object):
def __init__(self):
print 'Guten Morgen!'
def sag_hallo(self):
print 'Hallo, wie geht es dir?'
mein_auto = Auto()
mein_auto.sag_hallo()
Python im Web: Django - Florian Herlings, 21.10.2009 19/48
20. Klassen
class Auto(object):
def __init__(self):
print 'Guten Morgen!'
__init__ = Konstruktor
def sag_hallo(self):
print 'Hallo, wie geht es dir?'
mein_auto = Auto()
mein_auto.sag_hallo()
Python im Web: Django - Florian Herlings, 21.10.2009 20/48
21. Klassen
class Auto(object): Referenz auf das aktuelle Objekt
def __init__(self):
print 'Guten Morgen!'
def sag_hallo(self):
print 'Hallo, wie geht es dir?'
mein_auto = Auto()
mein_auto.sag_hallo()
Python im Web: Django - Florian Herlings, 21.10.2009 21/48
22. Klassen
class Auto(object):
def __init__(self):
print 'Guten Morgen!'
def sag_hallo(self):
print 'Hallo, wie geht es dir?'
mein_auto = Auto() Ausgabe:
mein_auto.sag_hallo() Guten Morgen
Hallo, wie geht es dir?
Python im Web: Django - Florian Herlings, 21.10.2009 22/48
23. Das reicht erstmal!
Aber es gibt noch viel mehr auf python.org
Python im Web: Django - Florian Herlings, 21.10.2009 23/48
24. Eigentlich ging es ja um...
Python im Web: Django - Florian Herlings, 21.10.2009 24/48
25. Python im Web: Django - Florian Herlings, 21.10.2009 25/48
26. The Web framework for perfectionists with deadlines.
Python im Web: Django - Florian Herlings, 21.10.2009 26/48
27. The Web framework for perfectionists with deadlines.
die coolste Punchline aller Zeiten
Python im Web: Django - Florian Herlings, 21.10.2009 27/48
28. Django:
- Web(2.0)-Framework
- 100% Buzzword-kompatibel
- MVC (oder so ähnlich)
- ORM
- viele, kleine Applications (Blog, Backend, User-Verwaltung, ...)
- Backend-Generator
- Schnell (sehr schnell)
- BSD-Lizenz (wie die meisten Python-Projekte)
Python im Web: Django - Florian Herlings, 21.10.2009 28/48
43. Mehr auf
djangoproject.com
Python im Web: Django - Florian Herlings, 21.10.2009 43/48
44. Eine Sammlung von bereits erstellten, generischen Apps,
die sich nahtlos in eine bestehende Django-Projekte
einbetten lassen.
Projekt-Seite: pinaxproject.com
Python im Web: Django - Florian Herlings, 21.10.2009 44/48
45. Features
openid support
email verification
password management
site announcements
a notification framework
user-to-user messaging
friend invitation (both internal and external to the site)
a basic twitter clone
oembed support
gravatar support
interest groups (called tribes)
projects with basic task and issue management
threaded discussions
wikis with multiple markup support
blogging
bookmarks
tagging
contact import (from vCard, Google or Yahoo)
photo management
Python im Web: Django - Florian Herlings, 21.10.2009 45/48