On 2013-06-11 08:54, Chris Angelico wrote: > >> Another principle similar to 'Don't add extraneous code' is > >> 'Don't rebind builtins'. > > > > OK, we've all done it by accident (especially when starting out), > > but are there people that rebind builtins intentionally? > > There are times when you don't care what you shadow, like using id > for a database ID.
While that's certainly the most common, there are a lot of items in __builtins__ that are there for convenience that I wouldn't think twice about rebinding, especially in a local scope (I might take more care at a module scope, but still wouldn't care much). E.g. apply bin buffer coerce filter format input Some are deprecated, some are easily replaced by (what I consider more readible) list comprehensions, and some have alternate meanings that might be the right word-choice inside a function and wouldn't be missed (I'd expect to see a bin-sort function use variables called "bin" and not needing to convert from integer-to-string) And some strings that are harmless outside the interactive interpreter copyright credits exit license quit -tkc -- http://mail.python.org/mailman/listinfo/python-list