Comment

Comment by mar77i

I wonder why anyone would think inverting semantics like this was anything but asking for disaster.

With all the metaprogramming that is possible, will the matching Cat(age=age) even produce a coherent object that has an age argument passed to __init__? Do keyword arguments in those patterns work on properties? How will it compare to another cat, is that using "is" or __eq__?

Does Cat have to derive from the same type object?

    def Cat(**kwargs):
        return type("Cat", (), {"__init__": lambda self, **kw: ([setattr(self, k, v) for k, v in kw.items()], None)[-1]})(**kwargs)
parent mar77i 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton