Category: Python
Keeping things in sync: derive vs test
There are times when we need to stop trying to make everything sync automatically, and just test that it is synced. Tips for Python and web dev.
pyastgrep and custom linting
Methodology and sample code for using pyastgrep to do custom linting tasks on Python source code.
Enforcing conventions in Django projects with introspection
Some code and tips to combine Python and Django introspection APIs to enforce naming conventions in your Django models.
Python packaging must be getting better - a datapoint
I “pip install”ed my app on Windows and everything just worked. Something is going right.
Python Type Hints: pyastgrep case study
A second, and more successful attempt to use static type checking in a real Python project
Django and Sass/SCSS without Node.js or a build step
How to use Sass/SCSS in a Django project, without needing Node.js/npm or running a build process
The different uses of Python type hints
5 different things you might be using type annotations for, or might want to.
Python’s “Disappointing” Superpowers
A response to Hillel Wayne’s “I am disappointed by dynamic typing”
Test factory functions in Django
Patterns for creating model instances in Django project test suites, and some anti-patterns
Python Type Hints: case study on parsy
How I tried and failed to add static type checking to Parsy, and settled for type hints as documentation instead.
Tools for rewriting Python code
A collection of tools that can be run to automatically rewrite Python code in a number of ways
Better Python code grepping with pyastgrep
Release announcement for pyastgrep, a tool for grepping Python code at the syntax level.
Raising exceptions or returning error objects in Python
How returning error objects can provide some advantages over raising exceptions in Python, such as for static type checking tools.
REPL Python programming and debugging with IPython
The flows I use for exploratory programming using a REPL and their advantages.
A Django PAGNI: efficient bulk properties
When using Django database models and adding a calculated property of some kind, you should probably ensure it will be efficient in bulk even if that isn’t needed yet.
Evolution of a Django Repository pattern
Everything is an X
Analysis and examples of the popular high-level pattern of making all the things in your system conform to a common interface.
Test smarter, not harder
Tips for winning the automated testing battle.
Announcement: Django Views - The Right Way
Announcement of my guide to writing Django Views.
Keyword-only arguments in Python
Keyword-only arguments are a feature that has been around since Python 3.0 but I've not seen them used much. This post explores the how and why.
Double-checked locking with Django ORM
How to implement the classic double-checked locking pattern with Django ORM/PostgreSQL.
Pylint false positives
Some analysis on the false positive rate when using Pylint on a codebase.
A Look at Python, Parameterized
How to replace 6+ design patterns with one concept in Python
WordPress 4.7.2 post mortem
Some lessons from the recent WordPress vulnerability
Django admin tips Twitter account
Follow @djangoadmintips for curated tips about the Django admin
Avoid Django's GenericForeignKey
Why Django's GenericForeignKey is (usually) a bad idea
A simple password-less, email-only login system
A simple password-less login system to consider for some use cases, with Django code.
We need less powerful languages
We need languages and systems that are less powerful, not more powerful, and easy ways to create and use such languages.
My approach to Class Based Views
A way to use Class Based Views and avoid some of the problems with Django's versions.
IPython Notebook Essentials review
A review of the above book by L. Felipe Martins.
Handling Django's get_query_set rename is hard
Trickiness surrounding subclassing
You can’t compare language features, only languages
Why I think we need the context of a language to have meaningful debate about language features.
How to learn Django without installing anything
Pretty much what it says in the title...
Things that can be self-hosting
An attempt to put something down about the idea of self-hosting software
Zero-based indexing in the real world
An example that might help a new programmer struggling with the insanity of counting from zero.
Wedding hacks - seating planner using simulated annealing
Some attempts to solve the seating headache with software.
Wedding hacks - making A4 booklets from A5 PDF sheets
The order of service requires some Python hacking
Wedding hacks - John Lewis gift list hyperlink
Using my programming skills for higher purposes, part 1
MVC is not a helpful analogy for Django
We should just introduce people to MVT
Bundling dependencies
Some answers and questions on the subject of bundling copies of dependencies in a project
Best practices with Django on WebFaction
WebFaction should encourage a much better deployment process
Now it's your turn
Porting a Django app to Python 3
Controlling Sozi remotely from an Android phone
Success story with Linux, Chrome, Android, Coversal and Python
Full screen WebView Android app
A complete WebView Android app, full screen, with a progress bar and back button that works as normal
Dynamic typing in a statically typed language
An example of why dynamic typing in a statically typed language can be painful
Why escape-on-input is a bad idea
With examples from the web development world especially PHP, and lessons for Pythonistas
PHP, Python and Persuasion
Notes to self on how (not) to convince people.
Moved to blogofile and disqus
I switched my site/blog to blogofile and disqus, sorry for any incovenience for feed readers.
Never fix a bug twice
A response to "Things you should test" by Noah Sussman.
Django's CBVs were a mistake
Django's CBVs are complex, unpythonic solutions to simple problems, (IMHO :-), here's why.
Reasons to love Django, part x of y
I've probably written lots of blog posts on this, so I can't claim 'x' = 1, and I've no idea what 'y' is...
LearnScripture.net launched
I launched my new Django Bible memorization site, LearnScripture.net
KTimeTracker replacement - TimeCult
TimeCult works well, and I wrote a script for converting KTimeTracker files.
Async Raven/Sentry client with Django/Python
How to do logging calls to Sentry asynchronously (until Sentry gets UDP support).
Some quick Django optimisation lessons
Some tips for keeping your Django apps lean and mean from the beginning, using lessons from django-fiber,
A prayer to the programming gods
O gods of software development and operations, I have sinned. Your anger falls on me, and I feel your wrath...
Announcing django-easyfilters (with some heresy on the side)
Announcing django-easyfilters, a new library for Django, and a bit of heretical editorial about Django's ORM.
Dissecting Python - part 1
First part of a series of posts that attempt to explain Python by the dissection method.
Docs or it doesn't exist
Writing good quality documentation for the software libraries you publish always matters. Otherwise, you are doing the world a disservice by publishing.
django-anonymizer released
An app to help protect your customers' data when in development.
Class Based Views and Dry Ravioli
Class based views are very cool. I am starting to clean up an existing project using them, and lots of existing views are turning into declarative code. But it makes me worried about the ravioli effect.
player_do – control multiple media players from a single (command line) interface
I tend to use several music/media players, such as shell-fm, moc and Clementine. In order to be able to use the media buttons on my keyboard for pausing/skipping, I wrote this Python script to automatically route the commands to the right one.
Exploratory programming with IPython
Using IPython deep inside a program...
Mercurial tree visualisation
I discovered hgview, a really great replacement for hgk.
Eclipse and Mercurial with existing checkout
How can I get the Mercurial Eclipse plugin to just recognise an existing folder as a Mercurial repository?
Eclipse, PyDev, Django and virtualenv
How I set up Eclipse to work with an existing project using virtualenv
Is static type checking a redundant testing mechanism?
Based on my recent Haskell experience, I highlight some cases where I think static type checks provide a better testing mechanism than unit tests or other automated tests.
Python and copyright
A lot of discussion recently has missed the point: the big question is whether the terms of any software licence are really relevant to dynamic languages...
Emacs and personal trac wiki
I've blogged before about using trac as a personal wiki, now I've found I can use Emacs as my editor and trac browser it's even better...
Review: Django 1.0 Template Development
A review of "Django 1.0 Template Development" by Scott Newman, from Packt Publishing.
Multiple output formats in Django
An article from Django 1.0 Template Development by Scott Newman, about how to output a document in multiple formats/styles using Django templates.
Managing Django patches using Mercurial
A simple way to use Mercurial Queues in a Subversion working directory to manage patches before committing to Subversion.
Django, Python 2.5 and memory usage
After reading that in Python 2.5 some big memory leaks are fixed, I just switched a Django site from Python 2.4 to Python 2.5. I wasn't disappointed -- the combined memory usage of my Apache processes (which are using mod_python) went from 100Mb to 60Mb. So, for anyone else wanted to conserve memory, this is the first thing I'd suggest!
Django newforms-admin upgrade
Django newforms fixes lots of things...
Bible memorisation web app
I created a system and web app to help me organise my Bible memorisation. And I rant a bit Django and web.py.
Django and Twill
How to use Twill within Django unit tests
Personal wiki and desktop integration
Some tools to help organise your computer and files.
AJAX validation with Django, newforms and MochiKit
I present below some example code for using Django, newforms and MochiKit to do AJAX validation, in case anyone else is doing the same, complete with a live demo...
O'Reilly code quiz
My results on the O'Reilly's code quiz...
Null pointers vs None vs Maybe
Why Haskell's 'Maybe' totally pwns Python's 'None' and null pointers.
Django validator updated
I've updated my `validator app `_ to latest Django trunk and finally done a release.
Why learning Haskell/Python makes you a worse programmer
A rant about how annoying programming in C# is, really.
Understanding Monads Via Python List Comprehensions
An attempt to explain monads and their usefulness in Haskell, assuming only some simple knowledge of Python.
Pyrex and Lisp
Paul Graham was right again...
A Django website that took (a lot) more than 20 minutes.
An attempt to debunk some of the '20 minute web app' hype that is so prevalent at the moment, and present a more realistic and balanced account of the Django site I have just finished.
Empty files and templates
I've noticed in Python and in Django I almost always create a module or a template by starting with a completely empty file, and typing...
Leading whitespace in comments
I fixed my blog comments so that leading whitespace is now preserved – making it much more friendly to posted Python code.
pychecker vs pylint vs Django
Using pychecker and pylint on Django – and each other...
Django Admin Hack - Fields varying with user permissions
Here is a not-too-awful hack to make the admin give different 'add/change' forms depending on who is using it.
Cross Site Request Forgeries
I've implemented a module that provides protection against Cross Site Request Forgeries for Django - and as always with both Python and Django, I've got that "surely it can't be that easy" feeling...
Django
Just discovered the Django web development framework, and I think I'm in love...