Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

How to get the names of the Python functions in the call stack?

$
0
0

Hi all

I am looking for a way to get the name of a Python function from inside the function.
I tried by the inspect module, callin the stack() function …


import inspect

def f1():
  s = inspect.stack()

f1()

… but I get a “__main__” error.

image

… And obviously, the error message shows me all those function names. :slight_smile:
But I’d like to get them without making the script crash.

How can I do that ?

Thanks !

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles