Introspecting the variable bound to a function argument

Anton Shepelev anton.txt at g{oogle}mail.com
Wed Feb 22 05:32:39 EST 2023


Hello, all.

Does Python have an instrospection facility that can
determine to which outer variable a function argument is
bound, e.g.:

   v1 = 5;
   v2 = 5;

   def f(a):
       print(black_magic(a)) # or black_magic('a')

   f(v1) # prints: v1
   f(v2) # prints: v2

-- 
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments


More information about the Python-list mailing list