On Fri, May 4, 2012 at 4:30 AM, cj <natsugre...@gmail.com> wrote: > Hi to all, > > Just wan't to ask if its possible. > > at helper.py > > def myfunc(): > blah blah blah > > and then in views.py > > def myview1(): > myfunc() > > def myview2(): > myfunc() > > my question is how can i get the caller function from myfunc(). > > i'm a newbie at python django so i hope you can help me. > > Thanks in advance. > > Cheers >
Not got much to do with django tbh, you will get more complete help on an actual python mailing list. However: import inspect def stack_inspector(): print "In stack_inspector()" stack = inspect.stack() print "Called from %s" % stack[1][3] def func1(): print "In func1()" stack_inspector() >>> func1() In func1() In stack_inspector() Called from func1 http://docs.python.org/library/inspect.html Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.