> encode = lambda x: x.encode("utf-8", "ignore")
Why not rather call it s (short for str)?
> With tuple unpacking, using _ as a throwaway label is also OK.
Use __ (double underscore) instead so it won't clash with the gettext convention:
from django.utils.translation import ugettext as _
> always use args and kwargs for variable argument listsNo, no, no, no, no! Why not clarify what are those accepted arguments?
What the following code is doing?
def shuffle(*args):
# do something
It shuffles SOMETHING.And this?
def shuffle(*cards):
# do something
It shuffles CARDS. Big difference IMO.> Use parens (...) for fluent APIs
I don't like that.
> Use implicit continuations in function calls
PEP8 suggest: "The preferred place to break around a binary operator is after the operator, not before it."
Following this logic, this should be:
return set((key.lower(), val.lower()) for
key, val in mapping.iteritems())
(for at the end of the first line)> Rarely create your own exception types
> ... and when you must, don't make too many.
Sorry but that's plain stupid.
> if item vs if item is not None
Yes, you should absolutely care. Not all the times, but sometimes a "NULL" value is different than a filled, but empty value. See zero. It's falsy, but totally acceptable input...