I think I can learn a lot from any answer to the two questions in this post.
OK, I’ve got a large object. That object has attributes and does things.
Those attributes also do things. MOST of what they do is sit there like a list, int, or np.array and wait to tell something else what to do. BUT SOMETIMES, they’ve got to do something on their own.
So, I can’t do, for instance
if method.attribute == something:
I’ve got to instead do
If method.attribute.value == something:
I can get around this with lists or ints by making a class with a “default” value and additional methods:
But I can’t do that with arrays, so I sometimes end up with ugly stuff like
if method.attribute.value(key).value == something:
So, two questions:
Have I gone completely wrong?
If not, what is the canonical way to guard against initializing a new instance with
NewInstance = ClassName(OldInstance, *args)
when I meant
NewInstance = ClassName(OldInstance.value, *args)
Right now, I’m doing something like
class ClassName(object): def __init__(self, value, *args): self IsClassNameInstance = True if hasattr(value, ‘IsClassNameInstance’): raise # some error