Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python's Functional Tools
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Julian Gindi
December 03, 2013
Programming
840
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python's Functional Tools
Advanced Python Magic
Julian Gindi
December 03, 2013
Other Decks in Programming
See All in Programming
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
act1-costs.pdf
sumedhbala
0
210
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
480
AIエージェントで 変わるAndroid開発環境
takahirom
2
490
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
260
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
830
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
360
霧の中の代数的エフェクト
funnyycat
1
330
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
330
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.3k
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
310
Rails Girls Zürich Keynote
gr2m
96
14k
Marketing to machines
jonoalderson
1
5.6k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
320
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
260
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
650
Odyssey Design
rkendrick25
PRO
2
730
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Design in an AI World
tapps
1
260
The Mindset for Success: Future Career Progression
greggifford
PRO
0
410
Transcript
Functional Python Tools Advanced Python Magic
I’m Julian Gindi • Python developer at iStrategylabs (here) •
(small-time) Python core contributor • github.com/juliangindi • @JulianGindi • JulianGindi.com • lebowski.juliangindi.com
Python @isl • Django (content-heavy websites) • General scripting and
internal tools • Fabric (executing commands on our servers) • Salt (provisioning our servers)
Goals • Basic understanding of functional programming • Explain how
it can help you craft simple, yet powerful code • Show you a couple practical applications of the functional paradigm
Golden Circle
Functional Programming (What) • First class functions. Higher-order functions •
Pure functions • State • Immutable Data • Verbs instead of nouns
Python? • Not a functional language in a “pure” sense
• Multi paradigm language • Doesn't really matter - tools are still useful and awesome • Practical
Why? • Downright awesome • Programs are easier to understand
and debug • Often faster • Superior ability to deal with concurrency
How? • Time for some CODE!
>>> my_tuple = ('A', 'B', ‘C’) >>> len(my_tuple) 3 >>>
my_tuple.append('D') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'tuple' object has no attribute 'append'
Practical Features (Core) • Closures • Lambda’s • Iterators, generators
• Partials • List Comprehension • Tuples • Built in functions (map, reduce, apply)
# List Comprehensions def square_list(items): new_list = [] new_list.append([x
* x for x in items]) return new_list ! print square_list([1,2,3]) ! >> [1, 4, 9]
# Closures ! def average_closure(a, b): def sum(): return a
+ b return sum() / 2 ! print average_closure(4, 4) ! >> 4
import operator ! # Lambdas ! def weird_average(func, data) :
return reduce(operator.add, map(func, data)) / len(data) ! print weird_average(lambda x: x * x , [1,2,3]) ! >> 4.66
# Generators ! def fibonacci() : prev, current = 0,1
while True : yield current prev, current = current, prev + current ! # Generator instantiation gen = fibonacci() ! # Generator usage for i in range(10) : print gen.next() ! >> 1 1 2 3 5 8 13 21 34 55
# PARTIALS ! from functools import partial ! def power(x,y):
return x ** y ! square = partial(power, y = 2) cube = partial(power, y = 3) ! assert (square(5), cube(7)) == (25, 343) ! ! !
How to get started • ‘import functools’ • Create a
simple program in a functional style • http://www.defmacro.org/ ramblings/fp.html - Functional programming for the rest of us • Execution in the Kingdom of Nouns