Skip to content

Instantly share code, notes, and snippets.

Bjørn Friese bearfrieze

Block or report user

Report or block bearfrieze

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bearfrieze
bearfrieze / slides.css
Last active Mar 28, 2016
Slides for "Comprehensions in Python the Jedi way"
View slides.css
pre {
font-size: 1.5rem;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
img {
@bearfrieze
bearfrieze / comprehensions.md
Last active Aug 22, 2019
Comprehensions in Python the Jedi way
View comprehensions.md

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

You can’t perform that action at this time.