Skip to content

Instantly share code, notes, and snippets.

View maxcell's full-sized avatar

Prince Wilson maxcell

View GitHub Profile
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

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.

Here is a non-exhaustive list of books that have influenced how I think about software.

@cassidoo
cassidoo / burrito
Last active November 19, 2016 05:47
Prompt: Write about your favorite memory with food
When I was a young child, about 5 or so, I dreamt of writing shows. I wanted to make my words on paper come to life on screen. I didn't even know how to write. But I had to try.
I started small, writing short stories about my socks or my gangster brothers. But I wanted more. I wanted to create something that would touch lives forever. But who was I? A 5-year-old suffering artist, struggling to get by? How could I stand out in the throngs of other authors and be who I truly was?
I had to write about something universal. I knew only my few friends and my family, who simply didn't understand me. Instead, I called a fellow artist in Brooklyn, Jay-Z. He gave me the best advice I could have asked for: "Leave it alone" (I couldn't tell if he said "it" or "me" but that was all I needed).
That was it. I needed to go specific. One, single thing.
I narrowed it down to food. Everyone eats. Everyone needs and wants food. It's the most basic desire and necessity we have. It's its own entity.
It was a genius plan. I wrote