you know the builtin function locals(). i could pass that to a function instead of passing a whole bunch of variables and getting a whole bunch of them back. i'd just need to code all the accesses in the functions as dictionary accesses.
i wrote a function named caller_locals() that, for the caller of caller_locals(), caller_locals() returns it's caller's locals. so with that, i don't even need to pass locals() to those in-context functions.
i wrote a function named caller_locals() that, for the caller of caller_locals(), caller_locals() returns it's caller's locals. so with that, i don't even need to pass locals() to those in-context functions.
from inspect import currentframe def caller_locals(): frame = currentframe() if not frame:return None frame = frame.f_back if not frame:return None frame = frame.f_back if not frame:return None return frame.f_locals
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.