Python

now browsing by category

 

Django Unit Testing with Mocks

Unit tests shouldn’t be treated like lesser code. It should be as clean as possible and don’t ever hesitate when it comes to refactoring the unit test code. It can save you a lot of trouble in the long run.

Python SysAdmin script for emails

Here’s some code I wrote maybe over 2 years ago for managing an email account database on my server. And yes, the mysql database password is in there. It’s a good thing the username no longer exists so the password doesn’t work. Oh and the server is offline because IRead More

yelpapi, a pure Python implementation of the Yelp v2.0 API

yelpapi, a pure Python implementation of the Yelp v2.0 API This looks really good, I really like how simple it is: The reason I created yelpapi is because I wanted to create an implementation that was completely flexible with regards to both input (i.e., it uses **kwargs) and output (i.e.,Read More

follow_redirects

follow_redirects I wrote a small utility tool for following HTTP redirects. Needed it for testing the redirects from a desktop site to a mobile site and for testing redirections when using URL shortening services. Came in handy and let me learn how to use the Python Requests library which isRead More

PyCharm: Markdown mode can display a Preview

I just discovered something great and something that will help me document projects. Sometimes I wonder how the README of a project will look on github or bitbucket and the only way for me to check is to push my changes, fire up the browser, go to the repo andRead More

Presentation: Why PyCharm

Just created a short presentation for work about why I’m checking out the PyCharm IDE. I wrote a post earlier about it. Update: found a nice post by a VIM user who switched to PyCharm and found it awesome how integrated everything is.

Django filter versus get for single object?

Django filter versus get for single object? While at work, we use a particular pattern in Django for getting a single object. We first filter the queryset by the id or slug and then check if the queryset exists. If so, then we return the object otherwise we return none.Read More

Validating File uploads in Django 1.0

While working on Clapton, the Django-based Content Management System (CMS), I had to write validation code for file uploads. This is needed because Clapton contains applications specific to media types such as documents which requires Word Documents, PDFs or OpenDocumentFormat files, and podcasts which requires MP3 or OGG files. But how doRead More