Introspecting the variable bound to a function argument

Hen Hanna henhanna at gmail.com
Wed Feb 22 15:12:10 EST 2023


On Wednesday, February 22, 2023 at 2:32:57 AM UTC-8, Anton Shepelev wrote:
> 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; 


do some Python coders like to end lines with   ;   ?


> 
>         def f(a): 
>                    print(black_magic(a))            # or black_magic('a') 
> 
>         f(v1)            # prints: v1 
>         f(v2)            # prints: v2 
> 

the term  [call by name]  suggests  this should be possible.


30 years ago...  i used to think about this type of thing A LOT ---
         -------  CBR, CBV, CBN,   (call by value),    (call by name)....   etc.



More information about the Python-list mailing list