IDLE question: "you may still have to reload nested modules."

2016-03-06 Thread alien2utoo
Hello list, I am following "Learning Python: Mark Lutz" and came across following in chapter 3 few days back. [quote] * You may still have to reload nested modules. Technically speaking, IDLE's Run->Run Module menu option always runs the current version of the top-level file only; imported

Re: Reason for not allowing import twice but allowing reload()

2016-03-06 Thread alien2utoo
>From the discussions in this thread, I get the impression that there are >genuine requirements to reload() a module during a program's execution. It is fairly easy to see reload() in context of interactive execution, but how does it come into picture in case of non-interactive Python program ex

Re: Reason for not allowing import twice but allowing reload()

2016-03-06 Thread alien2utoo
Based on the input from members, and my subsequent reading the textbook/tutorials, let me summarize my understanding of "why subsequent imports of same module are designed to be effect-less". 1. Imports are costly affair, as it involves - finding the module's file - compile it to byte code (if

Re: Reason for not allowing import twice but allowing reload()

2016-03-05 Thread alien2utoo
Steven, > There are better ways to manage your Python path than to manually insert > paths into sys.path like that. What version of Python are you using? I would love to know, apart from PYTHONPATH and sys.path.append() route. I am using Python 2.7.11 to start with as suggested by my employer. -

Re: Reason for not allowing import twice but allowing reload()

2016-02-29 Thread alien2utoo
> Why does one use (something like) idle? > To experiment. > > So what's your experiment-focus? True. Experiment only. What happens (and in environment) when you use - import module - from module import name - from module import name as othername Idle is start point, but we aren't always going t

Re: Reason for not allowing import twice but allowing reload()

2016-02-29 Thread alien2utoo
> As for need of import in Idle session, I use it to > - import sys > - sys.append.path('D:\\Where\\Ever\\My\\Modules\\Lie') Kindly read above as sys.path.append() > - import mymodule -- https://mail.python.org/mailman/listinfo/python-list

Re: Reason for not allowing import twice but allowing reload()

2016-02-29 Thread alien2utoo
Hello Rustom, F5 in Idle restarts the Python interpreter (that's what my impression is). Whatever you have done earlier at Idle prompt (in Idle session) before F5 is gone after F5. Try simple experiment at prompt. >>> myvar="hello" >>> myvar 'hello' myvar is gone after F5. As for need of imp

Re: Reason for not allowing import twice but allowing reload()

2016-02-29 Thread alien2utoo
Thanks Chris and Ian, Your suggested experiments and explanations have really provided some good insights, something Tutorial didn't indicate. Ian's explanation reminds me of #ifndef _HEADER_H_ #define _HEADER_H_ ... #endif // _HEADER_H_ in C/C++, and I can draw parallels to why subsequent a

Reason for not allowing import twice but allowing reload()

2016-02-28 Thread alien2utoo
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 ge