Reason for not allowing import twice but allowing reload()

alien2utoo at gmail.com alien2utoo at gmail.com
Mon Feb 29 01:40:04 EST 2016


Hello list,

We can not import a module twice in a session of Python (subsequent attempts to import same module don't result in any error though, but it is not-effective).

However after making change to module, we can reload() it (if not reload(), we could possibly have reimport statement) to get the updates in module.

I am a newbie in Python (learning via IDLE) and trying to understand

- what is extra (special) that import does, that reload() doesn't?
- if both do the same internally and externally, why subsequent imports of same module are ineffective?
- if subsequent imports of same module in a session are not effective, why not simply flag those attempts as an error, rather than letting them go effect-less.

Kindly help me understand the reasons behind.

Regards
Sandeep


More information about the Python-list mailing list