Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Job Security (in Python) (Christopher Neugebauer)
Search
PyCon Canada
August 25, 2013
Education
580
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Job Security (in Python) (Christopher Neugebauer)
PyCon Canada
August 25, 2013
Transcript
37 slides
Hello Canadia!
Job Security (in Python) Christopher Neugebauer @chrisjrn http://chris.neugebauer.id.au
Hello!
Why do people code Python?
“Readability” -- Raymond Hettinger, PyCon US 2013
“Readability Counts” -- Tim Peters, “The Zen of Python” (import
this)
PEP 0008 “Style Guide for Python Code”
None
Readability Sucks.
1. People can comprehend your code.
2. You can maintain your own code.
3. Your code will be more readily reusable.
THIS IS ALL BAD.
How do I write unmaintainable code?
1) Obvious variable names
1) Obvious (to you) variable names
• Callables: Superheroes • Classes: Musical characters • Strings: Famous
actors • Numbers: Movie characters
MerryPoppins.captain_america(matt_damon, james_bond)
Spiderman.spiderman(spiderman)
2) Metaprogramming
class Collection(Magic): def get_spam(self): return self.spam def set_spam(self, default): self.spam
= default
>>> c = Collection() >>> c.set_spam(“eggs”)
>>> c = Collection() >>> c.set_spam(“eggs”) Traceback (most recent call
last): File "<stdin>", line 1, in <module> File "<stdin>", line 10, in __getattribute__ TypeError: instancemethod expected at least 2 arguments, got 0
Help on Collection in module __main__ object: class Collection(Magic) |
Method resolution order: | Collection | Magic | __builtin__.object | | Methods defined here: | | get_spam(self) | | set_spam(self, default)
TRANSLATE = (("get","_bork_"), ("set","_bork_"), ("canhas" , "get"), ("ihasa" , "set"))
class Magic(object): def __getattribute__(self, attribute): oa = attribute for (key,val) in TRANSLATE: attribute = attribute.replace(key, val) try: return object. __getattribute__(self,attribute) except AttributeError: return type(object. __getattribute__(self, oa))
c.ihasa_spam("foo") -> c.set_spam(“foo”) c.canhas_spam() -> c.get_spam()
3) Monkey patching
“A batteries-included standard library” -- Raymond Hettinger, PyCon US 2013
Roll your own standard library
>>> import math >>> math.cos(0)
>>> import math >>> math.cos(0) 0.0
>>> import magic >>> import math >>> math.cos(0) 0.0
import math math.cos, math.sin = math.sin, math.cos
- End -
This talk was a joke.
Don’t do this.
The end. Christopher Neugebauer @chrisjrn http://chris.neugebauer.id.au
More Decks by PyCon Canada
See All by PyCon Canada
Sad Panda Needs a Hug (Nina Zakharenko)
pyconca
0
530
Shopify Checkout (Chris Saunders)
pyconca
0
280
Saturday Morning BreakfastSerial: Hacking Arduinos in Python (Swift)
pyconca
2
200
Skyfield and 15 Years of Bad APIs (Brandon Rhodes)
pyconca
0
490
Planting Open Source Seeds (Kenneth Reitz)
pyconca
0
190
Why Open Source Works (Alex Gaynor)
pyconca
0
280
How to learn Python in 5 Minutes (Daniel Moniz)
pyconca
0
1.1k
Sunday Morning Keynote (Karen Brennan)
pyconca
0
380
Saturday Morning Keynote (Jacob Kaplan-Moss)
pyconca
2
150
Other Decks in Education
See All in Education
HCI Research Methods - Lecture 7 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.8k
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 NISO Training Series, Session Two: Fair Use and the Public Domain"
baltimoreniso
0
170
パラグラフから始めるアカデミック・ライティング
neuroiwm
3
2.8k
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 NISO Training Series, Session One: Foundations & Frameworks of Copyright"
baltimoreniso
0
180
Before You Scale: Understand the Theory Behind the Simulation
pfn
PRO
1
210
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 NISO Training Series, Session Four: Copyright in Pop Culture and Digital Media"
baltimoreniso
0
170
GOVERNOR ADDRESS 1 :延岡 研一 氏(国際ロータリー第2720地区:2026-2027年度 地区ガバナー・人吉ロータリークラブ ・人吉電気工事株式会社 会長)卓話 : 2026.10.26例会・卓話
2720japanoke
0
670
Liburd and Stoll Farrell "Copyright Essentials From A to AI: A 2026 NISO Training Series, Session Three: Exceptions for Libraries"
baltimoreniso
0
160
LEGO Geometry Tutorial
arnoknobbe
0
820
1002
cbtlibrary
0
520
HTTP APIs in Python
madhuri28
0
130
自己紹介 / who-am-i
yasulab
6
7.5k
Featured
See All Featured
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
RailsConf 2023
tenderlove
30
1.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
320
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
350
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
530
BBQ
matthewcrist
90
10k
Writing Fast Ruby
sferik
630
63k