How to make a variable's late binding crosses the module boundary?

Antoon Pardon antoon.pardon at vub.be
Wed Aug 31 04:06:56 EDT 2022



Op 31/08/2022 om 09:53 schreef dn:
> On 31/08/2022 19.38, Antoon Pardon wrote:
>>
>> Op 30/08/2022 om 23:52 schreef dn:
>>> The conversation seems to be wandering some way from the OP. Whereas
>>> both of these answers are clever (and I assume work), the question
>>> becomes: why would you want to do this? (especially as it looks ugly and
>>> 'smells' a bit convoluted). An example use-case from your experience?
>>>
>>>
>>> Delving into the list-archive, to get back to the OP: the first message
>>> in the thread quotes another message that's (apparently) not present.
>>>
>>> However, in there somewhere is:
>>>
>>>> from test import *
>>> So, the elephant-in-the-room has always been a very stinky 'code-smell'
>>> - which pretty much every text or web-tutorial will say is a bad idea.
>> No that is a red herring. If for some reason a variable in a module has
>> to be (re)set after import time, it doesn't matter whether someone uses
>>
>>      from module import *
>>
>> or
>>
>>      from module import resetable_variable
>>
>> in both cases the module that did the import will not notice the change
>> in the original module.
>>
>> focussing on the code smell, is leading the attention away from the
>> problem.
> Are you the OP?
>
> The behavior has been shown to be exactly that which is (should be)
> expected.

That doesn't contradict that the behaviour is a problem. What is expected
(viewed as a language specification) and what is desired (viewed from what
would solve the problem easily) can be at odds.

-- 
Antoon Pardon.



More information about the Python-list mailing list