Python Worst Practices

Chris Angelico rosuav at gmail.com
Sat Feb 28 03:58:25 EST 2015


On Sat, Feb 28, 2015 at 7:48 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Fri, Feb 27, 2015 at 9:42 PM, Dan Sommers <dan at tombstonezero.net> wrote:
>> 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?
>
> If you have a dict that you want to key on object identity rather than
> equality, then you can use object ids as the keys.

And not forget to hang onto references to all those objects, else
their ids will be meaningless.

ChrisA



More information about the Python-list mailing list