> On Wed, Feb 17, 2021 at 9:11 PM Sven R. Kunze <[email protected]> wrote:
> >> Still think that "object()" should be writable since this seems like an
> >> arbitrary restriction
...
> But I guess there's been discussion around this already.
>
> ... but changing object would be problematic.
Well, yes, due to backward compatibility -- though how much code is
counting on not being able to add attributes to an instance of object?
I think someone on this thread (sorry can't find it now) said something
like:
if you could add attributes to object(), then you'd be able to add
attributes to subclasses of object. -- but you can already:
Isn't every class a subclass of object?
class C:
pass
C.this = "something"
c = C()
c.that = "something else"
It seems the difference is that both a new class and class instances get a
__dict__. But given that all classes derive from object, and object is of
type type, and classes are of type type -- I still have no idea why we
can't add things to an instance of object.
I suppose adding stuff to the object class itself would be very weird -- as
that would mess with ALL classes. But adding to an instance of object? why
not?
-Chris B
--
Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/SZJB5K4ADOM5RXKXCYBFV5RAJI22SG3Q/
Code of Conduct: http://python.org/psf/codeofconduct/