Before I ask this, do note: I want this for debugging purposes. I know that this is going to be some bad black magic, but I want to use it just during debugging so I could identify my objects more easily.
It's like this. I have some object from class A
that creates a few B
instances as attributes:
class A(object):
def __init__(self)
self.vanilla_b = B()
self.chocolate_b = B()
class B(object):
def __init__(self):
# ...
What I want is that in B.__init__
, it will figure out the "vanilla_b"
or whatever attribute name it was given, and then put that as the .name
attribute to this specific B
.
Then in debugging when I see some B
object floating around, I could know which one it is.
Is there any way to do this?