On 18/02/24 13:21, Jonathan Gossage wrote:
The problem is that if you are dealing with a library class, you may have times when the superclass is 'object' while at other times, with a different inheritance hierarchy, the superclass may need arguments. My thought is that the object class __new__ method should not choke on arguments, just ignore them.

All true.

So, what you're looking for is one mechanism to rule them all?

Not going to happen: for exactly the reasons you've stated. If you really want to get right 'down into the weeds' with a __new__() constructor, then you're well into customisation-territory.

I think it would be 'going nuts' but...
If it 'absolutely, positively, ...' then perhaps introspect the super-class and modify the call based-upon whether it is 'something' or "object"? (in similar fashion to the singleton's if-statement attempting to make sure it is unique)

- perhaps someone knows a better/proper way to do this?

Suggested research: custom classes, ABCs, and meta-classes...

See also recent improvements to Python which have made it easier for sub-classes (and Descriptors - __set_name__() ) to identify who/how/where to 'phone home', in case (also) applicable...


When I talk about 'object', I am talking about the ultimate base class of any inheritance hierarchy.  have seen the class named 'object' called that.

Correct.

The earlier comment was that

    class S( object ):

is 'tradition', and synonymous with:

    class S:

(not disputing the concept of "object" as the base class)


Not correct.

Please see last paragraph from previous message:


On Sat, Feb 17, 2024 at 7:06 PM dn via Python-list <python-list@python.org <mailto:python-list@python.org>> wrote:
...

    PS please reply to the list - there may be others who can learn
    from, or
    contribute to, this conversation!
...

--
Regards,
=dn

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to