Marko Rauhamaa <ma...@pacujo.net> writes:

> Ben Finney <ben+pyt...@benfinney.id.au>:
>
> > First reason: This is better done by making it clear the value is an
> > arbitrary object that won't be compared for equality. Just use
> > ‘object()’ to creeate each value and be done with it. That's a hack,
> > but it's better than pretending you'll use the string as a string of
> > text and then breaking that expectation.
[…]
> > So, I think Marko's use case is not a justification for comparing
> > string values with ‘is’.
>
> […] However, since any distinct objects will do, there is nothing
> preventing you from using string objects.

As has been pointed out to you, the whole point here is that string
objects often *are not* distinct, despite conceptually having distinct
cretion in the source.

That's why an ‘object()’ invocation is recommended: because it *will*
create distinct objects. Strings do not have that property. So strings
are *not* suitable for this use case.

-- 
 \     “It is hard to believe that a man is telling the truth when you |
  `\      know that you would lie if you were in his place.” —Henry L. |
_o__)                                                          Mencken |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to