Reason for not allowing import twice but allowing reload()

Chris Angelico rosuav at gmail.com
Tue Mar 1 06:39:36 EST 2016


On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> I cannot imagine why you would want to reload() in production code. That
> would imply that your production code is modifying already-imported
> modules, then wanting to import them again. Why would anyone in their right
> mind do that? Possibly because they lost a bet?

BartC and I have both done this exact thing, though neither of us used
Python for it. It's not so insane as you might think; sometimes you
want to update code, but you don't want to restart a process. Just
because you've never had a process that hits a year of uptime doesn't
mean nobody else does. :)

ChrisA



More information about the Python-list mailing list