Archive

Archive for December, 2012

Pyrate

December 31, 2012 Leave a comment

Today I came across a new word: pyrate, which means a python hacker. I love this word!

Happy New Year everyone. Happy hacking in 2013!

Categories: python Tags: ,

SQLite: prevent SQL injection

December 31, 2012 2 comments

DON’T do this:

cmd = "update people set name='{0}' where id='{1}'".format(name, id)
curs.execute(cmd)

DO this instead:

cmd = "update people set name=? where id=?"
curs.execute(cmd, (name, id))

If you are using MySQL or PostgreSQL, use %s (even for numbers and other non-string values!) and if you are using SQLite, use ?.

Tip from here.

Categories: python Tags: , , ,

2012 in review

December 31, 2012 Leave a comment

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

19,000 people fit into the new Barclays Center to see Jay-Z perform. This blog was viewed about 70,000 times in 2012. If it were a concert at the Barclays Center, it would take about 4 sold-out performances for that many people to see it.

Click here to see the complete report.

Categories: python Tags: , ,

A name generator in Python

December 30, 2012 Leave a comment

Problem
Sometimes you need a name for a registration or for a new profile in a game. What name to choose?

Solution
Use a name generator. Here is one in Python: Markov chains name generator in Python.

Categories: python Tags: ,

Python uses timsort for sorting

December 30, 2012 Leave a comment

TIL that Python uses timsort as its standard sorting algorithm.

Some links:

Python.org Mercurial Repositories

December 30, 2012 Leave a comment
Categories: python Tags: , , ,

Pycoder’s Weekly archive

December 28, 2012 Leave a comment
Categories: python Tags: ,