Skip to content

Instantly share code, notes, and snippets.


Daniel Roy Greenfeld pydanny

View GitHub Profile

Want to to come work with me at a $US2 billion dollar unicorn fighting climate change so our children have a greener future?

If you can you legally work right now in the USA, UK, Australia, Japan, Germany, or New Zealand, please apply by clicking the link below. We're hiring for many kinds of skills (marketing, design, customer support, etc), not just writing software.

If you can't yet legally work in one of the listed countries, don't worry. In the months and years to come we'll be opening offices in more countries around the world.

# Python start-up file
# --------------------
# Ensure a PYTHONSTARTUP environment variable points to the location of this file.
# See
# Stolen 100% from David Winterbottom's file that I can't find right now.
# Always have pp available
from pprint import pprint as pp
# Pre-emptively import datetime as I use it a lot.
zip = 90213 # common US developer mistake
id = 46
map = Map()
object = MyObject()
obj = MyObject()
object_ = MyObject()
map_obj = Map()
Audrey and I met on February 18, 2020. We were married on December 27th, 2020.
This programs calculates how much more we've been married than not married.
1. On November 4, 2017 our time married was now half the time we had been together.
2. On September 9, 2021 our time married will be twice as much as we knew each other.
3. On July 21, 2025, we
from datetime import datetime

Click "raw" and grab all the markdown!


Code style: black

View pytest.ini
addopts = --ds=config.settings.test --reuse-db -p no:warnings
python_files = test_*.py
pydanny /
Last active Aug 2, 2020
Within 12 hours of sending this email I got an apology. Sometimes it's better to write this out than quickly fire a customer.

There is nothing wrong in wanting to feed our families.

If I wanted to profit, I would stop selling digital versions of our books and only do printed versions. The last time we did that was for Two Scoops of Django 1.6, which made more than 1.5, 1.8, and 1.11 combined. That's the only way to put a halt to digital piracy: don't sell digital works. But that denies people in a lot of places access to our works. And means we're about pedagogy over profit.

We give hundreds of unpaid hours per year to open source projects. For years, every single book we've released we've given hundreds of print copies away as charity. Through books, articles, and open source contributions we have furthered people's knowledge around the world for over a decade.

All this means we're running a charity for the Python and Django community. These live classes are our means to hopefully do open source work for a living, with a few classes per month to cover our bills.

Can we make more money building apps for other people? Absolutely

# TODO: Add a comment above each line explaining what it does
# TODO: Add the ability to specify a game
# TODO: Make it so you don't have to run the script each time (while loop!)
# TODO: Convert this to use the Python built-in CSV library
from datetime import datetime
score = input("What score did I get? ")
with open("score.csv", "a") as f:
f.write(f"{}, {score}\n")
pydanny /
Created Jul 8, 2020
Which one is more legible?
def fun_function(name=None):
"""Find working ice cream promo"""
results =
results = results.filter(
Q(name__startswith=name) |
results = results.exclude(status='melted')
results = results.select_related('flavors')
return results
import sys
from django.core.signals import got_request_exception
from django.core.urlresolvers import reverse
from django.views.debug import technical_500_response
from django.utils.deprecation import MiddlewareMixin
class UserBasedExceptionMiddleware(MiddlewareMixin):
"""Allows superusers to see 500 debug pages in production"""