Hi

I will clarify my previous post, by making a stronger statement. Every
Python object is an instance of a class.

I wrote: Let's proceed. We continue to use d = Dummy(). Given that
       >>> key = d[1, 2, 3, a=4, b=5]
is allowed, what should we be able to say about the key. Clearly it should
be an instance of a class, and there should be a way of creating such an
instance without going via d. Let's call the class K (for key).

I'll now expand on this, as it's not clear to everyone that the key should
be an instance of a class.

So far I know, every Python object that is accessible to the Python user is
an instance of a class (or type). In fact, the type command tells us the
object's type.

    >>> [type(obj) for obj in (None, True, (), {}, [], type)]
    [<class 'NoneType'>, <class 'bool'>, <class 'tuple'>, <class 'dict'>,
<class 'list'>, <class 'type'>]

Using d = Dummy(), where d's __getitem__(self, k) simply returns k, we
write using the proposed new syntax
    >>> key = d[1, 2, 3, a=4, b=5]
and give this I suggest that
    >>> key2 = K(1, 2, 3, a=4, b=5)
should produce a key2 that is equal to key. Here
    >>> K = type(key)
should provide K.

I hope this helps clarify what I wrote. I also thank Alex Hall for
providing helpful clarification, from a different point of view.

-- 
Jonathan
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MHQTDJ6LNA3IYFONOWUOLTZFKSO4SUNU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to