import inspect


def _called_from_instance_init(instance, calling_frame):
  """ Helper to check a calling_frame is in an instance's __init__ """
  from_init = inspect.getframeinfo(calling_frame).function == "__init__"
  from_this = calling_frame.f_locals.get('self') is instance
  return from_init and from_this