Skip to content

Instantly share code, notes, and snippets.

@1N0T
Last active August 27, 2021 16:55
Show Gist options
  • Save 1N0T/46703880c5cb73cfd333ddff5c8c84d5 to your computer and use it in GitHub Desktop.
Save 1N0T/46703880c5cb73cfd333ddff5c8c84d5 to your computer and use it in GitHub Desktop.
(python) Determinamos el nombre de la función actual, así como desde donde ha sido llamada.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def mi_funcion():
import inspect
print(f"Ahora me encuentro en la función {inspect.stack()[0][3]}")
print(f"He sido llamado por {inspect.stack()[1][3]}")
def funcion_intermedia():
mi_funcion()
print("Llamada desde otra función")
print("==========================")
funcion_intermedia()
print("\n\n")
print("Lamada desde módulo principal")
print("=============================")
mi_funcion()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment