osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] About [].append == [].append


On Fri, Jun 22, 2018 at 9:43 AM Steven D'Aprano <steve at pearwood.info> wrote:

> On Fri, Jun 22, 2018 at 08:13:44AM -0700, Guido van Rossum wrote:
>
> > Honestly it looks to me like the status quo is perfect.
>
> Does this example work for you?
>
> py> (17.1).hex == (17.1).hex
> True
>
> But:
>
> py> a = 17.1
> py> b = 17.1
> py> a.hex == b.hex
> False
>
> I know why it happens -- at the REPL, the interpreter uses the same
> object for both 17.1 instances when they're part of the same statement,
> but not when they're on separate lines. I just don't know whether this
> is desirable or not.
>

But there's nothing new about that example. It's just the same as the issue
that sometimes `1 is 1` and sometimes it isn't.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180622/341f51c8/attachment.html>