Introspecting the variable bound to a function argument

Thomas Passin list1 at tompassin.net
Wed Feb 22 19:24:02 EST 2023


On 2/22/2023 3:12 PM, Hen Hanna wrote:
> 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   ;   ?

Very few, probably.  It's not harmful but adds unnecessary visual clutter.

>>
>>          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