SantaXL
SantaXL

Reputation: 654

Question regarding list's append() function

I have a short question:

is such statement:

a.append(x)
x is a[-1]

always true? a is a list, x can be anything (but I am particularly interested in big integers)

Upvotes: 0

Views: 22

Answers (2)

Philip Tzou
Philip Tzou

Reputation: 6438

In single thread yes, they are exactly the same even the references. For multiple threads not always: a could be changed by other threads.

Upvotes: 1

ohlr
ohlr

Reputation: 1909

Simple answer: Yes, it must always evaluate to true

Upvotes: 1

Related Questions