SlideShare a Scribd company logo
Why I love Python!
By Johannes Lundberg
@johannesl
Founder & CEO of 46elks
The Interpreter
>>> 1+1
2
>>>
>>> s = 'hello'
>>> s.uppercase()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute
'uppercase'
Dynamic typing
i = 1234
hostname = '127.0.0.1'
python -i
python -i hello.py
>>> print i
1234
Great native types
i = 1234
name = 'Johannes Lundberg'
startups = [ 'Kundo', '46elks' ]
options = {
'port': 12345,
'logpath': '../debug.log'
}
Native types are objects
>>> startups.sort()
>>> startups
['46elks', 'Kundo']
s = 'Rxc3xa4kenskapsxc3xa5r'
print s.decode('utf-8')
Räkenskapsår
options.has_key('logpath')
name.split(' ')[-1]
(123).bit_length
dir()
>>> dir(’Pycon Sweden 2015’)
['capitalize', 'center', 'count', 'decode',
'encode', 'endswith', 'expandtabs', 'find',
'format', 'index', 'isalnum', 'isalpha',
'isdigit', 'islower', 'isspace', 'istitle',
'isupper', 'join', 'ljust', 'lower',
'lstrip', 'partition', 'replace', 'rfind',
'rindex', 'rjust', 'rpartition', 'rsplit',
'rstrip', 'split', 'splitlines',
'startswith', 'strip', 'swapcase', 'title',
'translate', 'upper', 'zfill']
Functions as first-class citizens
def writelog(s):
pass
if options.has_key('logpath'):
f = open(options['logpath'],'wb')
writelog = f.write
OOP is not mandatory
players = []
for line in open('players.txt'):
if not line.startswith('#'):
players.append( line.strip() )
Awesome standard libraries
import hashlib
import ftp
import urllib
s=urllib.urlopen('http://ph4.se/').read()
hashlib.sha256(s).hexdigest()
…
Works everywhere
scp hello.py ph4labs.com:.

More Related Content

PDF
Python postgre sql a wonderful wedding
PDF
"PostgreSQL and Python" Lightning Talk @EuroPython2014
PDF
Programming with Python and PostgreSQL
PPTX
Coffee script
PPTX
Grails queries
PDF
PuppetDB, Puppet Explorer and puppetdbquery
PDF
Php arduino
PPTX
PHP 5.5.0 ChangeLog
Python postgre sql a wonderful wedding
"PostgreSQL and Python" Lightning Talk @EuroPython2014
Programming with Python and PostgreSQL
Coffee script
Grails queries
PuppetDB, Puppet Explorer and puppetdbquery
Php arduino
PHP 5.5.0 ChangeLog

What's hot (18)

PDF
Controlling Arduino With PHP
PDF
Green dao
PDF
Natural Language Toolkit (NLTK), Basics
PDF
5. Ввод-вывод, доступ к файловой системе
PDF
360|iDev
PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
PDF
Productive Programming in Groovy
PPTX
Introduzione a C#
PDF
Ramda, a functional JavaScript library
PDF
Jakarta Commons - Don't re-invent the wheel
PDF
No dark magic - Byte code engineering in the real world
PPTX
GreenDao Introduction
PPTX
2015 555 kharchenko_ppt
PPTX
Commit2015 kharchenko - python generators - ext
PPTX
What’s new in C# 6
PDF
Javascript ES6 generators
PDF
Opa presentation at GamesJs
PPTX
Optimizing Tcl Bytecode
Controlling Arduino With PHP
Green dao
Natural Language Toolkit (NLTK), Basics
5. Ввод-вывод, доступ к файловой системе
360|iDev
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Productive Programming in Groovy
Introduzione a C#
Ramda, a functional JavaScript library
Jakarta Commons - Don't re-invent the wheel
No dark magic - Byte code engineering in the real world
GreenDao Introduction
2015 555 kharchenko_ppt
Commit2015 kharchenko - python generators - ext
What’s new in C# 6
Javascript ES6 generators
Opa presentation at GamesJs
Optimizing Tcl Bytecode
Ad

Viewers also liked (18)

PDF
Why an api? - Exec I/O Mobile 2014
PPTX
Co curicular-140219110017-phpapp01
PDF
Islamic Concept of Ownership - (Urdu)
PDF
Imam Azam’s Benefitting from The Companions and Imams of The Prophet SAW’s H...
PDF
Can an API be too simple?
PDF
What is a game?
PDF
Voice Hackathons ifrån Vinnova Forum Öppna Data 2016-05-20
PDF
OpenTTD at trafiklab 2015 06-10
PDF
Sayyiduna Sideeq ay-Akbar’s Status of Nearness and Companionship - (Urdu)
PDF
Islamic Teachings Series (5): Cleanliness and Prayer - (Urdu)
PDF
A Collection of Prophetic Traditions on Divine Mercy - (Urdu)
PDF
Islam and Public Welfare - (Urdu)
PDF
Lightning Talk @ PyCon Stockholm 2016
PDF
Abp vs instruccion directa
PPT
Crianza de-pollos ZOOTECNIA GENERAL
PPTX
Enfermedades infecciosas de los animales
PPT
Zootecnia General
PDF
The Architecture of an API Platform
Why an api? - Exec I/O Mobile 2014
Co curicular-140219110017-phpapp01
Islamic Concept of Ownership - (Urdu)
Imam Azam’s Benefitting from The Companions and Imams of The Prophet SAW’s H...
Can an API be too simple?
What is a game?
Voice Hackathons ifrån Vinnova Forum Öppna Data 2016-05-20
OpenTTD at trafiklab 2015 06-10
Sayyiduna Sideeq ay-Akbar’s Status of Nearness and Companionship - (Urdu)
Islamic Teachings Series (5): Cleanliness and Prayer - (Urdu)
A Collection of Prophetic Traditions on Divine Mercy - (Urdu)
Islam and Public Welfare - (Urdu)
Lightning Talk @ PyCon Stockholm 2016
Abp vs instruccion directa
Crianza de-pollos ZOOTECNIA GENERAL
Enfermedades infecciosas de los animales
Zootecnia General
The Architecture of an API Platform
Ad

Similar to Why I love Python! (20)

PPTX
Python mcq questions excel your python knowledge
PPTX
GRADE 11 Chapter 5 - Python Fundamentals.pptx
PPTX
06.pptx
ODP
An Intro to Python in 30 minutes
PPTX
CH-3 FEATURES OF PYTHON, data types token
PDF
An introduction to Python for absolute beginners
PPTX
Introduction to Python Programming .pptx
PPTX
Python basics
PPTX
PYTHON PROGRAMMING.pptx
PDF
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
PPTX
Python.pptx
PDF
Python (3).pdf
PPTX
Lecture on Fundamentals of Python Programming-1
PPT
Introduction to python
PDF
Chapter 0 Python Overview (Python Programming Lecture)
PDF
python_strings.pdf
PDF
Introduction_To_Python (1)that helps you
PPTX
Python_Haegl.powerpoint presentation. tx
PPT
1B-Introduction_to_python.ppt
PPTX
python presentation
Python mcq questions excel your python knowledge
GRADE 11 Chapter 5 - Python Fundamentals.pptx
06.pptx
An Intro to Python in 30 minutes
CH-3 FEATURES OF PYTHON, data types token
An introduction to Python for absolute beginners
Introduction to Python Programming .pptx
Python basics
PYTHON PROGRAMMING.pptx
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
Python.pptx
Python (3).pdf
Lecture on Fundamentals of Python Programming-1
Introduction to python
Chapter 0 Python Overview (Python Programming Lecture)
python_strings.pdf
Introduction_To_Python (1)that helps you
Python_Haegl.powerpoint presentation. tx
1B-Introduction_to_python.ppt
python presentation

Recently uploaded (20)

PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PPTX
Mathew Digital SEO Checklist Guidlines 2025
PDF
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
PPT
250152213-Excitation-SystemWERRT (1).ppt
DOC
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
PDF
simpleintnettestmetiaerl for the simple testint
PPTX
E -tech empowerment technologies PowerPoint
PPTX
Database Information System - Management Information System
PPTX
artificial intelligence overview of it and more
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PPTX
Funds Management Learning Material for Beg
PPTX
Introduction to cybersecurity and digital nettiquette
PDF
Introduction to the IoT system, how the IoT system works
PDF
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PPTX
artificialintelligenceai1-copy-210604123353.pptx
PDF
Slides PDF: The World Game (s) Eco Economic Epochs.pdf
PPTX
t_and_OpenAI_Combined_two_pressentations
PPT
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
Mathew Digital SEO Checklist Guidlines 2025
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
250152213-Excitation-SystemWERRT (1).ppt
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
simpleintnettestmetiaerl for the simple testint
E -tech empowerment technologies PowerPoint
Database Information System - Management Information System
artificial intelligence overview of it and more
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
Funds Management Learning Material for Beg
Introduction to cybersecurity and digital nettiquette
Introduction to the IoT system, how the IoT system works
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
artificialintelligenceai1-copy-210604123353.pptx
Slides PDF: The World Game (s) Eco Economic Epochs.pdf
t_and_OpenAI_Combined_two_pressentations
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt

Why I love Python!

  • 1. Why I love Python! By Johannes Lundberg @johannesl Founder & CEO of 46elks
  • 2. The Interpreter >>> 1+1 2 >>> >>> s = 'hello' >>> s.uppercase() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'uppercase'
  • 3. Dynamic typing i = 1234 hostname = '127.0.0.1'
  • 4. python -i python -i hello.py >>> print i 1234
  • 5. Great native types i = 1234 name = 'Johannes Lundberg' startups = [ 'Kundo', '46elks' ] options = { 'port': 12345, 'logpath': '../debug.log' }
  • 6. Native types are objects >>> startups.sort() >>> startups ['46elks', 'Kundo'] s = 'Rxc3xa4kenskapsxc3xa5r' print s.decode('utf-8') Räkenskapsår options.has_key('logpath') name.split(' ')[-1] (123).bit_length
  • 7. dir() >>> dir(’Pycon Sweden 2015’) ['capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
  • 8. Functions as first-class citizens def writelog(s): pass if options.has_key('logpath'): f = open(options['logpath'],'wb') writelog = f.write
  • 9. OOP is not mandatory players = [] for line in open('players.txt'): if not line.startswith('#'): players.append( line.strip() )
  • 10. Awesome standard libraries import hashlib import ftp import urllib s=urllib.urlopen('http://ph4.se/').read() hashlib.sha256(s).hexdigest() …