language ➤ Object oriented ➤ Interpreted (sometimes JIT compiled) ➤ Strongly typed with dynamic semantics ➤ Syntax emphasizes readability ➤ Supports modules and packages ➤ Cross platform since the beginning ➤ Very mature: 20+ years in the making ➤ Comes with batteries included ➤ Rich ecosystem ➤ Strong, welcoming and passionate community
if name == “david bowman”: print(“Hi old friend”) else: print(“Nice to meet you”) print(“My name is HAL9000”) def main(): guest = input(“What is your name?”) hello(guest)
➤ code blocks start with ‘:’ ➤ whitespace really matters ➤ there are no braces ➤ there are no parentheses ➤ there are no semicolons ➤ spaces over tabs by convention ➤ IDEs and editors follow conventions! def hello(name): if name == “Nicola”: print(“Hi old friend”) else: print(“Nice to meet you”) print(“My name is HAL9000”) def main(): guest = input(“What is your name?”) hello(guest)
public void Serialize() { // ... } public override string ToString() { return "I am a document"; } } Python class Document( object ): def serialize(self): # ... def __str__(self): return "I am a document."
{ float total = 0; foreach (var item in cartItems) { total += item.Item2; } return total; } } } Console.WriteLine("Total price: {0}", cart.TotalPrice); Python class ShoppingCart: @property def total_price(self): total = 0.0 for item in self.items: total += item[1] return total print("Total is {0}".format(cart.total_price))
{ int current = 1; int next = 1; yield return current; while (true) { int temp = current + next; current = next; next = temp; yield return current; } } Python def fibonacci_generator(): current, nxt = 1, 1 yield current while True: current, nxt = nxt, current + nxt yield current
.NET developers, by Michael Kennedy ➤ Learn Python the Hard Way, by Zed Shaw ➤ Python in 10 minuti (Italian), by Nicola Iarocci ➤ The Python Tutorial, python.org ➤ Google
development environment on Windows ➤ Python folks finally have a great development environment on Windows ➤ .NET crowd can build stuff in Python using their favorite IDE and toolset ➤ Python is a great second language for C# developers ➤ Diversity is good. And it matters.