From something like this:
print(get_indentation_level())
print(get_indentation_level())
print(get_indentation_level())
I would li
Yeah, that's definitely possible, here's a working example:
import inspect
def get_indentation_level():
callerframerecord = inspect.stack()[1]
frame = callerframerecord[0]
info = inspect.getframeinfo(frame)
cc = info.code_context[0]
return len(cc) - len(cc.lstrip())
if 1:
print get_indentation_level()
if 1:
print get_indentation_level()
if 1:
print get_indentation_level()