Python Worst Practices

Dan Sommers dan at tombstonezero.net
Fri Feb 27 23:42:25 EST 2015


On Sat, 28 Feb 2015 12:09:31 +1100, Steven D'Aprano wrote:

> There's no harm in calling a local variable "id", if you don't use the
> built-in id() inside that function. That's one of the reasons why functions
> exist, so that the names you use inside a function are distinct from those
> outside.

And thank goodness for that!  I've been writing Python code since 1997
and version 1.5.<something>,¹ and I still do a double take when emacs
colors all my ids that faint blue that means "builtin."

I don't think I've ever used the builtin function id in a program.
Ever.  Not even once.  Honestly, what is a valid use case?  That said, I
do have boatloads of parameters and objects locally named id because
it's idiomatic (at least to me) and mnemonic (at least to me) and just
as meaningful.

¹ No, not continuously.  I have eaten and slept since then.



More information about the Python-list mailing list