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
The `max` function
Search
Eloy Zuniga Jr.
April 17, 2018
Programming
69
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The `max` function
Using the `max` function in python 3.6. Some caveats to watch out for.
Eloy Zuniga Jr.
April 17, 2018
More Decks by Eloy Zuniga Jr.
See All by Eloy Zuniga Jr.
The Filter Function
eloy
0
91
The Command Line Interface
eloy
2
520
Python Decorators
eloy
8
640
Other Decks in Programming
See All in Programming
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
330
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
190
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
150
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
730
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
130
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
260
仕様駆動開発の消費期限
watany
20
8.8k
VibeCodingからAgenticWorkflowへ
starfish719
0
690
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
530
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
330
AIが無かった頃の素敵な出会いの話
codmoninc
1
470
AIを紡ぐPMのお話
swdtkuy
0
120
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7.1k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
290
It's Worth the Effort
3n
188
29k
[SF Ruby Conf 2025] Rails X
palkan
2
1.3k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
How to build a perfect <img>
jonoalderson
1
5.9k
Become a Pro
speakerdeck
PRO
31
6.2k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Speed Design
sergeychernyshev
33
2k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
620
Transcript
max() caveats to consider
Max function # Assume `L` is a list of datetimes,
Nonetypes L = get_dates() max(L) # returns biggest item @eloy · python 3.6 · 2018 2/11
Original code component_times = max( rr_time, spo2_time, o2device_time, t_time, sbp_time,
hr_time) @eloy · python 3.6 · 2018 3/11
Empty sequence # Can we get a max item from
an empty sequence? max([]) @eloy · python 3.6 · 2018 4/11
Handle TypeError # Lets handle the `TypeError` try: max([]) except
TypeError: pass # Lets write less and make it more readable max([], default=None) @eloy · python 3.6 · 2018 5/11
None list # Can we get a max item from
a list of Nonetypes? L = [None, None] max(L) @eloy · python 3.6 · 2018 6/11
Handle ValueError # Lets handle the `ValueError` L = [None,
None] try: max(L) except ValueError: pass # What if `L` had both datetimes and Nonetype values? L = L + get_dates() @eloy · python 3.6 · 2018 7/11
Remove None items # Remove Nonetypes before using Max max([i
for i in L if is not None]) @eloy · python 3.6 · 2018 8/11
Does this work? # Remove Nonetypes before using Max L
= [None, None, None] max([i for i in L if is not None]) @eloy · python 3.6 · 2018 9/11
With default param # Remove Nonetypes before using Max L
= [None, None, None] max([i for i in L if is not None], default=None) @eloy · python 3.6 · 2018 10/11
Filter # Remove Nonetypes before using Max max(filter(None, L), default=None)
@eloy · python 3.6 · 2018 11/11