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

Antoon Pardon antoon.pardon at vub.be
Wed Aug 31 03:38:19 EDT 2022



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.

-- 
Antoon Pardon


More information about the Python-list mailing list