[Python-ideas] Jump to function as an an alternative to call function

Brice Parent contact at brice.xyz
Fri Aug 17 04:41:04 EDT 2018



Le 16/08/2018 à 20:34, Steven D'Aprano a écrit :
> On Thu, Aug 16, 2018 at 10:31:28AM +0200, Brice Parent wrote:
>
>> If I understand well the need (I'm unsure I've had it myself), it would
>> be easier to be able to import the function in the active context, like
>> this:
>>
>> def foo(a):
>>      return a + c
>>
>> def bar(a, c):
>>      return foo(a)
>>
>> def bazz(a, c):
>>      import __file__.foo
>>      return foo(a)
> [...]
>> I'm not saying the syntax is the one that should be used (__file__
>> possibly not existing may be a problem), not even saying that we should
>> have this. I'm just showing a way to do the same thing with an easier
>> (to me) syntax.
> The problem isn't that __file__ doesn't exist, it is that import DOES
> exist and does something completely unsuitable:
>
> [...]
That's what I was trying to say: I'm not proposing a syntax or any 
specific solution.
It was more about graphically explaining that I found more explicit 
(that word again...) to import (or copy, or insert) the target function 
inside the active scope than to have it done when you call the function 
itself.



More information about the Python-ideas mailing list