class MyClass(properties.HasProperties):
pass
MyClass(some_function=0)
But this doesn't...
class MyClass(properties.HasProperties):
def some_function(self):
...
MyClass(some_function=0)
This isn't a huge deal; I mean, you can override any attribute once the object is created. It's just super strange that __init__ allows this implicitly.
HasProperties.__init__
takes arbitrary key word arguments and assigns them to existing properties. However, it also has a strange behaviour: if the kwarg is not a property but is an existing attribute - https://github.com/seequent/properties/blob/6daa40a5bfdc58a14b707ab4bd8cc0b733a82781/properties/base/base.py#L313 - it overrides the attribute - https://github.com/seequent/properties/blob/6daa40a5bfdc58a14b707ab4bd8cc0b733a82781/properties/base/base.py#L324 If the kwarg is neither a property nor an existing attribute,__init__
raises anAttributeError
- https://github.com/seequent/properties/blob/6daa40a5bfdc58a14b707ab4bd8cc0b733a82781/properties/base/base.py#L314For example, this errors:
But this doesn't...
This isn't a huge deal; I mean, you can override any attribute once the object is created. It's just super strange that
__init__
allows this implicitly.