Determine calling module's name

jeffgray at my-deja.com jeffgray at my-deja.com
Thu Aug 10 22:52:20 EDT 2000


  Roland Mas <mas at echo.fr> wrote:
> So, you raise an exception, and Bob's your uncle:

An excellent idea - tres bien! After a little work, I found the
following would operate correctly:

def LogMessage(message):
  try:
    raise Exception()
  except:
    modName=sys.exc_info()[2].tb_frame.f_back.f_locals.get('__name__')
  print modName,':',message

Thanks for your help
Jeff


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list