Hi, I'm Daniel Greenfeld, and welcome to my blog. I write about Python, Django, and much more.

10 reasons to go to DjangoCon Europe

Monday, May 14, 2012 (permalink)

You should go to DjangoCon Europe in lovely Zurich, Switzerland. Here are 10 reasons why:

1. Chocolate

So much of what we like about chocolate comes from Switzerland. For example, Milk Chocolate was invented in Switzerland.

2. Keynote speaker: Jacob Kaplan-Moss

Always a great speaker and fun to be around ...

Read more ...

2012 resolution summary

Sunday, December 30, 2012 (permalink)

Resolutions completed

  • Go to a Python related conference in North America, Europe, and Asia. Conferences I attended:

    • PyCon US
    • DjangoCon Europe
    • PyCon Philippines
    • PyCon Poland
  • See a place in the USA I've never been. A couple places I saw:

  • Drop to a 32 waist

  • Visit ...

Read more ...

Annotated History of My Most Used Shell Commands

Wednesday, April 10, 2013 (permalink)

An oldie, but a goodie. This time I annotate it with reasons as to why things are used so much. If you blog, post your own!

For reference, anything after a "#" is an annotation.

$ history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn |head ...
Read more ...

A Public Service Message to the Python Community

Monday, August 20, 2012 (permalink)

Hi, I'm Daniel Greenfeld. You might know me from my blog. I'm here to talk to you about a very import subject: Submitting your talk early to PyCon US.

Last year there were hundreds of talks were submitted for just a very few speaking slots. Unpaid volunteers labored ...

Read more ...

Announcing PyCon Philippines!

Saturday, June 09, 2012 (permalink)

PyCon Philippines 2012, set to occur on June 30 and July 1, is the first Python programming conference held in the Philippines. PyCon is a volunteer run effort that brings together Python developers from a variety of backgrounds and skill levels into a friendly, cooperative environment in order to educate ...

Read more ...

Announcing Two Scoops of Django 1.6!

Wednesday, February 05, 2014 (permalink)

http://twoscoops.smugmug.com/Pydannycom/i-M5FKCtv/0/M/two-scoops-django-co-authors-M.jpg

We (Audrey Roy and I) just released the revised, expanded, and slightly renamed second edition of our book on Django. It's called Two Scoops of Django: Best Practices for Django 1.6, and you can buy it right now in print format on our online store or Amazon.com ...

Read more ...

Attaching custom exceptions to functions and classes

Thursday, August 02, 2012 (permalink)

Having too many custom exceptions on a project can be a pain, but a few choices ones are really nice. The problem is that in complex libraries having to import both functions and exceptions becomes a drag. To mitigate having to remember to import custom exceptions, this is a handy ...

Read more ...

awesome-slugify: Human-readable URL slugs from any string

Tuesday, January 21, 2014 (permalink)

note: The introduction mentions Django and Plone. However, this is not an article about Django or Plone.

Introduction

Years ago, when I was working with Plone at NASA, one thing I dreaded was when content editors would copy-and-paste from Microsoft Word into the title bar. All kinds of funny characters ...

Read more ...

awesome-slugify: Human-readable URL slugs from any string (part 2)

Wednesday, January 22, 2014 (permalink)

In my previous blog post I covered using awesome-slugify to capture slugs in both ASCII and unicode. Today I'm covering the definition custom language slugify translation functions.

Defining Custom Language slugify Translation Functions

For those times we need ASCII representation of unicode characters, we can't always use the ...

Read more ...

Beginner's Guide to PyCon 2013 Part I

Tuesday, January 22, 2013 (permalink)

New to Python and thinking about going to the upcoming PyCon US for the first time? You know, that big Python conference taking place near San Francisco in March?

Or perhaps you signed up already and are getting worried about being overwhelmed by hundreds of tutorials, talks, and activities?

No ...

Read more ...

Beginner's Guide to PyCon 2013 Part II

Wednesday, January 23, 2013 (permalink)

This is Part II in a series of blog posts about PyCon US 2013. The goal is to provide a handy reference guide for first time attendees of the world's largest Python conference. Part I was mostly about tutorials, this post will be about registration and the first day ...

Read more ...

Beginner's Guide to PyCon 2013 Part III

Sunday, March 10, 2013 (permalink)

This is Part III in a series of blog posts about PyCon US 2013. The goal is to provide a handy reference guide for first time attendees of the world's largest Python conference. Part I was mostly about tutorials, Part II was mostly about the first day of talks ...

Read more ...

Beginner's Guide to PyCon 2014

Saturday, April 05, 2014 (permalink)

New to Python and/or conferences and attending the upcoming PyCon 2014 in Montreal, Canada? Or is this your first conference? Or perhaps your first conference longer than a weekend?

Hoping to get the most out of joining thousands of Python enthusiasts?

No worries! This guide will aid you in ...

Read more ...

Building, Maintaining and Scaling Projects

Tuesday, July 15, 2014 (permalink)

These are the slides from the talk I gave today at the Wharton Web Conference.

Read more ...

cached-property: Don't copy/paste code

Tuesday, July 01, 2014 (permalink)

In Python, the @cached_property decorator is a really nice piece of code. What it does is it caches the result of a property call. The cached result will persist as long as the instance does, so if the instance is passed around and the function subsequently invoked, the cached result ...

Read more ...

Calendar About Nothing

Wednesday, March 28, 2012 (permalink)

On October 16th, 2011, which was one hundred and sixty-four days before I published this post, I resolved to get myself onto the Longest Streak list of Calendar About Nothing. Today, with this blog post, I've managed to do just that - get on the Longest Streaks.

Calendar About Nothing ...

Read more ...

Case Study: URL Design for petcheatsheets.com

Wednesday, November 21, 2012 (permalink)

Backstory: On Saturday, November 17, 2012 Audrey Roy and I decided to participate in the Petcentric hackathon, a Los Angeles area Pet-themed product/coding contest held at Amplify. We arrived a bit late, but armed with Audrey's idea of creating a pet based reference sheet for owners, pet sitters ...

Read more ...

Choosing a new python based blog engine

Thursday, April 05, 2012 (permalink)

Why a new blog engine?

On my old blog, I had been having issues with Blogger for some time. The WYSIWYG text editor was annoying in that it produced wonky HTML, so I had to hand craft the posts. Which meant I often wrote the HTML formatted copy in a ...

Read more ...

Choosing an API framework for Django

Thursday, May 10, 2012 (permalink)

First off, out of the box, Django lets you construct API responses with a little work. All you need to do is something like this:

# Copied from https://docs.djangoproject.com/en/1.4/topics/class-based-views/#more-than-just-html
from django import http
from django.utils import simplejson as json

class JSONResponseMixin ...
Read more ...

Cookiecutter: Project Templates Made Easy

Saturday, August 17, 2013 (permalink)

Yesterday, Jeff Knupp wrote an amazing how-to article called "Open Sourcing a Python Project the Right Way". While I was reading it, I was rather pleased by just how close it is to my own practices. Considering Jeff's amazing Writing Idiomatic Python, it meant I was on the right ...

Read more ...

Core Concepts of Django Forms

Friday, March 29, 2013 (permalink)

In my opinion, the concepts behind Django's non-model forms can be listed in just three (3) bullets:

  • Forms render HTML.
  • Forms are "just" Python constructs.
  • Forms validate dictionaries (Python's Key/Value structure).

Let's dig in!

Forms render HTML.

If I construct a Django form:

# myapp/forms.py ...
Read more ...

Core Concepts of Django ModelForms

Thursday, June 13, 2013 (permalink)

In my opinion, the concepts behind Django's model forms can be listed in just six (6) bullets. The bullets I've marked in bold at the top are the topic of this blog post, while the two of these that were covered in a previous blog post on Django ...

Read more ...

CSS Hacking to make my code samples legible

Friday, May 11, 2012 (permalink)

I've been very happy with Pelican as a blog engine so far, and haven't even moved off the sample theme. There's just been one problem: Myself and others have had a lot of trouble reading the code snippets.

I didn't have time to cook up a ...

Read more ...

Curiosity has landed!

Monday, August 06, 2012 (permalink)

I'm terribly proud of what was accomplished last night: A car-sized robot weighing a whopping 8,580 pounds (3,893 kg) was landed on Mars. It is packed with scientific packages that will expand our knowledge of Mars, and has the power to use them for at least 14 ...

Read more ...

Deadline for DjangoCon Financial Aid requests is tomorrow!

Thursday, August 02, 2012 (permalink)

For 2012, DjangoCon US has moved to Washington, DC, and everyone is invited! If you need financial support to get there, the Django Software Foundation and PyLadies have paired with a number of forward thinking sponsors to help get you there. All genders are eligible for assistance, so don't ...

Read more ...

Developer Time

Tuesday, December 04, 2012 (permalink)

This blog post got started with a tweet.

That tweet got retweeted a lot by developers. And system administrators. And database administrators. And any creative type.

As of December 7th, 2012, it had been retweeted over 500 times, a personal best. Obviously I struck a chord that resonated with a ...

Read more ...

Django Class Based View: email form with CAPTCHA

Wednesday, May 23, 2012 (permalink)

Yesterday I showed how to implement a simple email form for Django using Class Based Views. Today I'm going to extend yesterday's work to use the excellent RECAPTCHA service to help reduce spam content.

This version requires pip installing the following into your virtualenv.

  • pip install django-crispy-forms so ...
Read more ...

Django GetOrCreateView

Tuesday, October 16, 2012 (permalink)

Today I decided to use the Django class based view (CBV) CreateView, but I wanted to avoid duplications and submit to the view from the front page of a site. The reason was I needed a simple newsletter signup form. This is what I cooked up and should work for ...

Read more ...

Django Requirements 2012-08-15

Wednesday, August 15, 2012 (permalink)

A little over three months ago I blogged about my preferred requirements list. It's now nearly the eve of Django Dash, and I feel it's time to update the list. I'm going to bump the versions on some of the existing packages and add some new ones ...

Read more ...

Django Requirements for a project

Wednesday, May 09, 2012 (permalink)

Today I'm starting a new project. I'm working as fast as I can and hope to launch on Friday. What are my package dependencies?

Django==1.4

Unlike my last quick project which was Flask, this effort really falls into Django's sweet spot. I need sessions, forms ...

Read more ...

django-uni-form end of life

Saturday, February 18, 2012 (permalink)

I started on django-uni-form in January 2009. In order to use Pinax on an internal social network for NASA HQ, we had to render all content, including forms, Section 508 compliant. Rather than rewrite the html for all 50+ forms that existed in the Pinax 0.5.x framework at ...

Read more ...

Django Update View without slug in the url

Saturday, July 28, 2012 (permalink)

Today I wanted to use the Django Class Based View (CBV) UpdateView but without a slug identifier in the URL. For example, instead of /profiles/pydanny/ I would go to /my-crazy-profile/. Also, I needed to force authentication.

I've done this with Django functional views a few times times, but ...

Read more ...

Docstrings and Various Python Objects

Wednesday, March 05, 2014 (permalink)

Early in my journeys with Python I struggled with understanding the purpose and use of lambda functions. When I finally understood them I was disappointed by their lack of docstrings. For that reason, and various other shortcomings, I went back to standard functions. Also, for what it's worth, I ...

Read more ...

Dynów 2013 Part I

Monday, September 09, 2013 (permalink)

note: This is the first part in a series about a family research trip to Dynów, Poland in May 2013.

This was our second trip to Poland. Last year (2012) I went with Audrey in 2012 for a few days to present at a software conference called PyCon Poland. We ...

Read more ...

EuroPython Intro to Django Workshop

Monday, July 01, 2013 (permalink)

We (myself and Audrey Roy) have been asked to fill in a tutorial session at EuroPython 2013 on the afternoon July 3rd! Therefore, it is my honor to announce our EuroPython Intro to Django Workshop! (see the bottom of this article for registration instructions)

Workshop Description

Bring your laptops and ...

Read more ...

Exceptions as Decorator Arguments

Tuesday, December 24, 2013 (permalink)

I wanted to see if I could have an exception as a decorator argument. Here is what I came up with:

import functools

class MyGoof(Exception):
    pass

def pass_goof(exception):
    def decorator(test_func):
        @functools.wraps(test_func)
        def wrapper(*args, **kwargs):
            try:
                return test_func(*args, **kwargs)
            except exception as e:
                return ...
Read more ...

My experiences with Django and Python 3

Thursday, July 11, 2013 (permalink)

The following are my notes, observations, and resources on the subject of working with Python 3 (with or without Django).

Recently I've become involved in a couple of Django efforts that used Python 3.3. The quick summary of what I learned is pretty much what I expected: Out ...

Read more ...

Fiction vs Non-Fiction

Monday, February 24, 2014 (permalink)

I'm a published author.

There, I said it. I co-wrote a book and its sequel. My childhood dream of becoming a writer has come true.

Well, not completely.

Truth is, I've always wanted to be a fiction author. Don't get me wrong, writing a technical book has ...

Read more ...

Filepicker.io and South

Tuesday, April 23, 2013 (permalink)

I've heard good things about filepicker.io, which is a service that makes file uploading a much better experience. Unfortunately, the Django package for filepicker.io doesn't work with South. When I try to create a migration using the filepicker.io field using code like the following...

# products ...
Read more ...

Fixing Python's String class

Monday, April 01, 2013 (permalink)

Ever wonder why Python's str or unicode types lack obvious length methods? Yes, we can get the length via the special __len__() method, but instead as Python developers we get the so-called 'luxury' of discovering length via the Python's built-in len() function. So instead of calling the length ...

Read more ...

Generating NCX files with Python

Monday, April 15, 2013 (permalink)

With the help of fellow Python developer Matt Harrison's excellent Ebook Formatting: KF8, Mobi & EPUB, we managed to create pretty decent looking Kindle and ePub versions of Two Scoops of Django.

One of many things we did was focus on providing an excellent table of contents. Of course we ...

Read more ...

Hola, Argentina!

Wednesday, August 13, 2014 (permalink)

I'll be arriving in Argentina on August 14th. I'll be speaking at PyDay Mendoza on August 15th, and sprinting on August 16th on something Audrey and I named the "new library sprint" (more details to come). On August 22nd, I'll be speaking at the combined Buenos Aires ...

Read more ...

I Married Audrey Roy

Saturday, January 04, 2014 (permalink)

In a small, private family ceremony on December 27th, 2013 I exchanged wedding vows with Audrey Roy.

https://s3.amazonaws.com/pydanny/vows.jpg

It was an incredible day. I'll savor the moment we promised ourselves to each other in matrimony forever. She is the other half of my soul, and since we've become husband ...

Read more ...

I use this

Saturday, February 25, 2012 (permalink)

I had been meaning to do this for some time, and even had a nascent page for it on this site already. I just noticed my old friend Jessica Hammer was featured on usesthis.com. Then I remembered Kenneth Reitz blogged about his tools not that long ago. Looks like ...

Read more ...

Installing Pycairo on Mountain Lion

Tuesday, September 04, 2012 (permalink)

Pycairo is the binding for the cairo graphics library. It's also not something you can get running with a simple pip install py2cairo. After many hours of working the search engines and dancing to the configure/make/make install melody, I figured out an answer that worked for me ...

Read more ...

Jinja2 Quick Load Function

Thursday, June 12, 2014 (permalink)

It seems like that for every few weeks I find myself needing to generate something out of a template while working outside a framework. For this task, my preferred solution is Jinja2. I've used Jinja2 to generate HTML, code, and text. If I were brave enough I would even ...

Read more ...

Join us at DjangoCon Europe!

Tuesday, April 10, 2012 (permalink)

This year in June, the European edition of DjangoCon is going to be held in lovely Zurich, Switzerland. It is my great fortune and delight to announce that Audrey and I will be attending. Hooray!

Needless to say, we're extremely excited. My trip to Europe in 2007 was an ...

Read more ...

July 15th, 2012 LA Open Source Recap

Monday, July 16, 2012 (permalink)

On July 15th, 2012, at the July LA Hackathons Open Source event, over 60 Python, Django, Ruby, Ruby on Rails, PHP, JavaScript, Node.js, Perl, and Clojure developers arrived to work on a variety of projects. We went from 10 AM to 10 PM, and there was much coding and ...

Read more ...

Launching our API at PyCon 2012

Friday, March 09, 2012 (permalink)

A few months ago me and my fiancee, Audrey Roy, launched our start up, Consumer Notebook. It's a Python powered product comparison site that combines the best features of Open Comparison, Yelp, Consumer Reports, and Pinterest. We've worked day and night to make it better, with countless members ...

Read more ...

Los Angeles Open Source Sprint on May 12th!

Tuesday, May 01, 2012 (permalink)

http://farm9.staticflickr.com/8022/7132778527_6e3b49b313_o.png

This is a day long coding event in Los Angeles for Open Source developers of all languages and skill levels to come and code like fiends. They'll be joined by dozens of either really smart coders or nice people like me. Sponsors are providing food, drinks, venue, and more ...

Read more ...

Los Angeles Open Source Sprint on Nov 4th!

Sunday, October 14, 2012 (permalink)

https://s3.amazonaws.com/pydanny/la_hackathons.jpeg

Yet again, myself, Audrey Roy, and a small but elite cadre of volunteers are feverishly at work putting together another Los Angeles open source event. Our last effort went smashingly well, and like any good engineer, we're ready to scale up - this time to 150 attendees!

LA Open Source ...

Read more ...

Made Up Statistics

Friday, July 26, 2013 (permalink)

Years ago my good friend Miguel Araujo and I presented on Advanced Django Form Usage. Slide 18 of that talk mentioned some made up statistics. Here they are for reference:

  • 91% of Django projects use ModelForms.
  • 80% ModelForms require trivial logic.
  • 20% ModelForms require complex logic.

In Chapter 10 of ...

Read more ...

May 12th, 2012 LA Open Source Recap

Monday, May 21, 2012 (permalink)

On May 12th, 2012, over 50 Python, C++, Ruby, PHP, JavaScript, and Node.js developers arrived to code on a variety of projects. It was awesome! Tons of open source projects saw contributions, and people across languages and frameworks worked together.

http://farm9.staticflickr.com/8007/7193954598_1b071cb5e4.jpg

Event Background

Less then two weeks before May 12 ...

Read more ...

Memories of Malcolm

Monday, March 17, 2014 (permalink)

A year ago today Malcolm Tredinnick, core contributor to Django suddenly passed away. He was a mentor, and more importantly, a good friend.

Here are some of my memories of Malcolm.

DjangoCon US: September 2010

This is where Audrey and I first met Malcolm. We ended up spending a good ...

Read more ...

My new blog

Friday, February 17, 2012 (permalink)

What I did to get it running:

pip install pelican
git clone git://github.com/pydanny/pydanny.github.com.git

My settings.py file:

AUTHOR = 'Daniel Greenfeld'
DISQUS_SITENAME = 'pydanny'
GITHUB_URL = 'https://github.com/pydanny'
GOOGLE_ANALYTICS='UA-18066389-2'
SITEURL = 'http://pydanny.github.com'
SITENAME = 'pydanny'
SOCIAL = (('twitter', 'http://twitter.com/pydanny'),
          ('github ...
Read more ...

My PyCon 2012 Schedule

Wednesday, February 22, 2012 (permalink)

Here I was thinking that this year's PyCon wasn't going to be so busy because I didn't submit a talk or tutorial. Ha! What the heck was I thinking?

Here's what I've already got in the works.

Wednesday, March 7th

Me and Audrey are driving ...

Read more ...

New Year's Meme 2013

Tuesday, December 31, 2013 (permalink)

Inspired by Alex Clark's meme, here is my own entry into this end-of-year fun.

What’s the Coolest Thing You Discovered This Year?

Alex had his own focused on Python applications, frameworks, and libraries. Me, I'm going for a more general approach. This year I discovered:

LaTeX

That ...

Read more ...

New Year's Python Meme 2012

Friday, December 28, 2012 (permalink)

Tarek Ziade has a habit of ending the year with a Python-themed meme. I've matched his meme the times he previousstarted it, and as you can tell from the title of this blog post I'm matching him yet again.

1. What’s the coolest Python application, framework or ...

Read more ...

New Year's Resolutions for 2013

Monday, December 31, 2012 (permalink)

I'm one of those people who not only likes to make New Year's Resolutions, I like to blog about them.

Resolutions

  • Go to at least one technical conference in South America, Asia, Africa, and Australia.
  • Visit at least one new nation. It's hard to come up with ...
Read more ...

New Year's Resolutions for 2014

Wednesday, January 01, 2014 (permalink)

Making News Year's Resolutions is something I do every year. It's important to me. I like to set goals and see how well I do.

Resolutions

  • Write and publish fiction. This is a childhood dream that I would like to do.
  • Write and publish as least one new ...
Read more ...

Off to Europe!

Saturday, April 20, 2013 (permalink)

I feel like I'm dreaming, but we're on our way to Europe!

A few weeks Audrey and I decided to move. While looking at possible rentals or even mortgages, we were idly (dreaming really... still paying off debts incurred from last year) looking at how much a room ...

Read more ...

Our Django Book Has Launched

Thursday, January 17, 2013 (permalink)

https://s3.amazonaws.com/twoscoops/img/tsd-cover.png

We (Audrey Roy and I) wrote a book on Django! It's called Two Scoops of Django: Best Practices for Django 1.5, and you can buy it right now in e-book (PDF) form on the website: http://django.2scoops.org.

Django, like any framework, has tips, tricks, and pitfalls ...

Read more ...

Overloading Django Form Fields

Wednesday, March 27, 2013 (permalink)

One of the patterns we get positive feedback for mentioning in our book is overloading form fields.

The problem this pattern handles is the use case of when we have a model with a field(s) that allows for blank values, how do we force users to enter values?

For ...

Read more ...

Parsing MongoDB URI

Monday, February 20, 2012 (permalink)

Rather than hard-code the configuration into a Python based settings file, when using a PaaS such as Heroku you want to pick up the MongoDB URI from the system settings. Here's what I do:

# get the dynamic elements from the MongoURI
import os
import re
r = r'^mongodb\:\/\/(?P ...
Read more ...

PyCon 2013 Talks/Tutorials I want to see

Monday, August 20, 2012 (permalink)

This morning, Jesse Noller, the chair of PyCon US, suggested a meme, "PyCon 2013 talks/tutorials I'd like to see". Here is my meme submission:

1. Python Obfuscation Contest

This certain-to-be-controversial talk idea would be where the speaker would solicit Pythonistas to submit a single arcane Python code module ...

Read more ...

PyCon Australia 2011 Review

Friday, February 24, 2012 (permalink)

In June of 2011 I had the good fortune of having my then girlfriend, Audrey Roy, now fiancee, invited to present a keynote speech at PyCon Australia 2011.

I was terribly excited for her to get that invitation, and that excitement was compounded when they allowed me to present on ...

Read more ...

PyCon Philippines 2012 Day 1

Tuesday, July 03, 2012 (permalink)

PyCon Philippines 2012 (PyCon PH) happened just this past weekend at the University of the Philippines Diliman (UP Diliman) campus in Quezon City, which is part of Metro Manila.

I can assure you that PyCon PH was an wonderful, amazing, humbling experience. I'm hoping that this post and others ...

Read more ...

PyCon Philippines 2012 Day 2

Thursday, July 05, 2012 (permalink)

The second day of PyCon Philippines 2012 had a really good turnout. My unofficial estimate is that we had about 90% of the attendees from the first day attend (with the unfortunate exception of most of the faculty and students of Agoo Computer College).

The day started with...

Lightning Talks ...

Read more ...

pytest: no-boilerplate testing

Wednesday, January 15, 2014 (permalink)

When I first encountered Holger Krekel's pytest this summer on Jeff Knupp's blog I felt like I had been living under a rock for years. I've been using Python's unittest framework since 2006 and nose to find tests since 2008, but here was another test framework ...

Read more ...

pytest: no-boilerplate testing (part 2)

Thursday, January 16, 2014 (permalink)

In my previous blog post I covered test discovery and writing basic tests using pytest. Today I'm going to cover a few more features that I really enjoy: raises and fixtures.

The Intuitively Named raises context manager

When using pytest, you can assert whether or not an exception occurred ...

Read more ...

pytest: no-boilerplate testing (part 3)

Friday, January 17, 2014 (permalink)

In my previous blog post I covered writing exception-based assertions and fixtures. Today I'm going to close things out by demonstrating how to change the behavior of pytest and how to integrate it with Django and setup.py.

Changing the Behavior of pytest

When pytest is called, either via ...

Read more ...

Python dictionary as a class

Saturday, September 01, 2012 (permalink)

A long time ago, circa 1999, when I was working in a certain procedural language I found a library that added objects to the language. It did so by playing interesting tricks with key/value structures, which in Python are called dictionaries. In 2005, as a new Python user, I ...

Read more ...

Python dictionary vs JavaScript object: Dynamic Keys

Sunday, August 19, 2012 (permalink)

One of the things I noticed a long time ago with JavaScript is that when you create objects you can define keys outside of strings:

> var o = {city: "San Francisco"}
  Object

In JavaScript, this is valid. In Python, you'll get a NameError:

>>> o = {city: "San Francisco"}
Traceback (most recent ...
Read more ...

Python Indie Bundle Cyber Monday Sale

Monday, December 02, 2013 (permalink)

I've joined forces with Matt Harrison and Audrey Roy to put together the first ever Python Indie Bundle sale!

This bundle includes the following e-book bundles (PDF, Kindle, ePub) for just $24.95:

  • Treading on Python Volume 1: Foundations
  • Treading on Python Volume 2: Intermediate
  • Two Scoops of Django ...
Read more ...

Python Partials are Fun!

Thursday, April 24, 2014 (permalink)

Writing reusable code is a good thing, right? The trick is to do so in a way that makes your life and those of others easier, but to do so in a very clear and maintainable way. Recently I've been playing around with Python's functools.partial function, which ...

Read more ...

Python Yields are Fun!

Friday, November 22, 2013 (permalink)

While you can optimize the heck out of your Python code with generators and generator expressions I'm more interested in goofing around and solving classic programming questions with the yield statement.

note: For this article, since it's easier to explain things as they happen, I'll be including ...

Read more ...

Result of our LA Migration Hackathon submission

Sunday, December 09, 2012 (permalink)

Possible Causes of for Internal Migration of Undocumented People

Our concept was to measure the effect of changing immigrant laws per state compared to income differences between regions. We present the following, which will be on it's own hosted site shortly:

Median Income over 5 years between States

Note ...

Read more ...

Selected for PyCon StartUp Row

Tuesday, February 21, 2012 (permalink)

Me and Audrey have been working hard on Consumer Notebook, a Python/Django based project. We submitted it to PyCon StartUp row and found out this morning we've been accepted. Hooray!

From the PyCon StartUp Row winner's post, here is a little bit of what we're about ...

Read more ...

Simple Django email form using CBV

Tuesday, May 22, 2012 (permalink)

Here's a simple FormView Class Based Views for Django. Here is a sample of how to do one as a simple email form. There is no CAPTCHA in this example, that's the topic of a future blog post.

This version requires the following packages pip installed into your ...

Read more ...

Simple HTTP Basic Auth Wall

Monday, July 09, 2012 (permalink)

I have a client who wanted their entire unlaunched public content site quickly but temporarily blocked for a short period of time. He wanted a universal password so he could send the site to reviewers, done quickly, and nothing else. In a few days the site will launch, and even ...

Read more ...

Stay with the Django CBV defaults!

Tuesday, November 27, 2012 (permalink)

One virtue of Django Class Based Views (CBVs) is that they come with pretty good default settings. The virtue of this is you can really pare your code down in size and complexity.

For example, here is an implementation of CBVs based on a straight-forward Django model , stuffage.models.Stuff ...

Read more ...

Surgery in Two Days

Wednesday, April 02, 2014 (permalink)

In two days, Friday, April 4th, I'm going into laparoscopic surgery in order to correct a double inguinal hernia. If you want to know what that is, you can read the Not Safe For Work (NSFW) Wikipedia article.

I said it.

I have a hernia.

That was hard.

It ...

Read more ...

The Easy Form Views Pattern Controversy

Friday, May 10, 2013 (permalink)

In the summer of 2010 Frank Wiles of Revsys exposed me to what I later called the "Easy Form Views" pattern when creating Django form function views. I used this technique in a variety of places, including Django Packages and the documentation for django-uni-form (which is rebooted as django-crispy-forms). At ...

Read more ...

The sorry state of Python OAuth providers

Monday, March 05, 2012 (permalink)

This is one of those challenging posts to write. The people whose projects I'm going to describe have put in a lot of dedicated, hard work to overcome a challenging subject. Writing an OAuth consumer is a hard problem and writing an OAuth provider is an even harder problem ...

Read more ...

Thoughts on my stack

Tuesday, September 04, 2012 (permalink)

I'm an open source developer. I use Python, Django, PostgreSQL, JQuery, MongoDB, Memcached, and Redis. I push production code to Linux servers.

And yet:

  • My laptop runs Apple's Mac OS X.
  • My primary editor is Sublime Text.
  • My production servers are provided mostly by Heroku.
  • All my sites ...
Read more ...

Thoughts on ranting

Monday, November 26, 2012 (permalink)

I'll admit it, I love a good rant. I respect those who can give rants well. I would list the ones I really like, but I'm not sure I want to deal with the arguments that would follow. ;-)

Of course, as much as I like to read or ...

Read more ...

Tools we used to write Two Scoops of Django

Friday, May 03, 2013 (permalink)

Because of the ubiquitousness of reStructuredText in the lives of Python developers and the advocacy of it, it's not uncommon for people to assume we used it to write our book. However, that's not really the case.

The short Answer is we used:

  • reStructuredText (RST)
  • Google Documents
  • Apple ...
Read more ...

Travel Tips for Geeks: Traveling Cheaply

Monday, August 05, 2013 (permalink)

It's a given that in order to travel you need to have money or make a lot of money, right?

That's not really true.

There are ways to live well but cheaply. It takes a bit of discipline, forethought, and judgement, but the reward of living is amazing ...

Read more ...

Travel Tips for Geeks: Preventing Theft

Thursday, July 18, 2013 (permalink)

This is the first in a set of blog posts based on my experiences traveling in various places around the world. This particular safety-related post is about theft, not scams, which I may cover in another article.

For this first article, I'm hoping this gets on various technical RSS ...

Read more ...

Tried out Jekyll

Thursday, February 09, 2012 (permalink)

Why Jekyll?

I've had issues with Blogger for some time. After my fiancee, Audrey Roy, moved her blog to https://github.com/mojombo/jekyll, I was impressed enough to give it a try.

Why did it impress me?

Code highlighting made easy

I don't have to hand-craft HTML ...

Read more ...

Two Scoops of Django 1.5 Beta Released

Thursday, February 28, 2013 (permalink)

After thirty four days of hard work, Audrey Roy and I are proud to announce that we've released the beta of Two Scoops of Django: Best Practices for Django 1.5. It's been a monumental effort, a labor of love, and we hope you find our efforts worthy ...

Read more ...

Two Scoops of Django FAQ

Monday, January 21, 2013 (permalink)

https://s3.amazonaws.com/pydanny/frontispiece.png

The launch of the Two Scoops of Django: Best Practices for Django 1.5 book has gone pretty well. The response has been almost entirely positive and sales have been pretty brisk. We've gotten a ton of great, constructive editorial feedback, which we're sorting through as we race ...

Read more ...

Two Scoops of Django is in print!

Wednesday, April 17, 2013 (permalink)

Since I was a child I wanted to be a published author. I've dreamt of people reading my book. While one could say that dream was fulfilled when we launched the e-book version in January, it's not the same as seeing the printed copy. Today I got to ...

Read more ...

Two Scoops of Goblins

Tuesday, April 01, 2014 (permalink)

While Audrey Roy Greenfeld and I were contemplating our next Two Scoops Press book topic, it came down to a decision between Pyramid, Flask, and mythical creatures. Inspired by Django's magical flying pony, Pyramid's scary alien dude, and even the idea of a magical Flask pouring out wonderful ...

Read more ...

Two years ago today

Friday, February 17, 2012 (permalink)

The PyCon tutorial on Django in Depth was ending. I had been sitting next to my friend Barbara and we got up to go when I heard a feminine voice ask: "Are you bshaurette?" I turned and it was like I got punched in the gut.

It was the first ...

Read more ...

Want to work for Eventbrite?

Wednesday, July 23, 2014 (permalink)

Join me, Andrew Godwin (South, Django migrations), Simon Willison (co-founder of Django, co-founder of Lanyrd), and many other talented people at Eventbrite. We have great challenges, the kind that inspire you to rise to the occasion. We need you to help us overcome them.

I should mention that Eventbrite is ...

Read more ...

Want to work for Eventbrite? (part 2)

Wednesday, July 23, 2014 (permalink)

For various reasons I had to change some things about my Eventbrite test. The new version is listed here and the previous blog post has been updated:

104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 115, 116, 46, 103, 105, 116, 104, 117,
98, 46, 99, 111, 109 ...
Read more ...

We are not using PayPal

Saturday, March 02, 2013 (permalink)

In January Audrey Roy and I launched a book about Django called Two Scoops of Django: Best Practices for Django 1.5. We decided to not use PayPal. Here's why:

Open Source Events Get Burned By PayPal

PayPal has a long, sordid history of freezing the accounts of Python ...

Read more ...

We need more PyCon US 2013 submissions!

Thursday, September 27, 2012 (permalink)

The PyCon US 2013 call for papers (CFP) ends tomorrow, September 28th, 2012. We need more talk and tutorial submissions. Talks are 30 or 45 minute efforts in front of the PyCon audience and are recorded for posterity. Tutorials are three hours long and are given to attendees who have ...

Read more ...

PyCon Tutorial: Wiring Up Django Packages

Friday, March 08, 2013 (permalink)

You just finished the Django tutorial. What now?

You learn how to Wire Up Django Packages!

This is a 3+ hour PyCon tutorial on March 14th at 1:20pm, in Santa Clara California at PyCon US.

In alphabetical order, the instructors:

Tutorial Description ...

Read more ...

You should Heroku

Tuesday, February 28, 2012 (permalink)

In mid-November me and my fiancee, Audrey Roy began our startup. We had been frustrated with trying to do on-line product research and came up with an idea to take the lessons learned from Django Packages / Open Comparison and apply them to a commercial effort. The result has been Consumer ...

Read more ...