About the implementation of del in Python 3
Chris Angelico <rosuav at gmail.com>:
> On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> What I'm looking for is snippets of Python code that illustrate the
>> That's how you can illustrate the difference between the "==" and "is"
>> >>> ["a"] is ["a"]
>> >>> ["a"] == ["a"]
> When you have an address, you can use that to locate the thing.
You are pulling that out of your hat (or a dictionary). Python doesn't
define the concept at all (yet it manages to locate every useful thing
> In C, that's pointer dereferencing. If I give you the id of a Python
> object, can you locate that object and find out something about it? If
> you can't, it's not an address.
> And you have to make this work in Python (the language), not just
> CPython (the interpreter). I'll consider an answer satisfactory if it
> runs on the Big Four - CPython, Jython, IronPython, and PyPy - and
> mainly, you need to show that it works in Jython, because that's the
> most different.
I don't follow you. A code example, please.
>> Unfortunately, when I try it, I get:
>> >>> a is a
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> NameError: name 'a' is not defined
> And oh how terrible, Python doesn't define any other operators on
> unassigned names either. The 'is' operator is looking at OBJECT
> identity, so you need to have an OBJECT. If you don't understand that
> part of Python's object model, I recommend learning from Ned
It's enough to point to the Language Reference if you have a link.
>>> First part is implied by Python's execution model,
>> [Citation needed]
Sorry, which sentence?
>>> and the second by the definition of the `is` operator.
>> [Citation needed]
That one in its entirety:
The operators "is" and "is not" test for object identity: x is y is
true if and only if x and y are the same object. Object identity is
determined using the id() function. x is not y yields the inverse
That simply defines the identity with whatever is returned by the id()
function. The id() function, in turn, is defined to be:
Return the ?identity? of an object. This is an integer which is
guaranteed to be unique and constant for this object during its
lifetime. Two objects with non-overlapping lifetimes may have the
same id() value.
which doesn't clarify anything.
> Just don't try explaining to a novice programmer that way. It's a
> waste of everyone's time.
I believe the concept of an object is among the more difficult things
for novice programmers to get.