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

2016-03-09 Thread Steven D'Aprano
Sorry for the delay in answering! On Sat, 5 Mar 2016 11:51 pm, alien2u...@gmail.com wrote: > 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 PYTHONP

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

2016-03-06 Thread Steven D'Aprano
On Sun, 6 Mar 2016 07:20 pm, alien2u...@gmail.com wrote: > 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". That is not correct. Imports are not a no-

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: Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-03-02 Thread Rustom Mody
On Thursday, March 3, 2016 at 9:38:11 AM UTC+5:30, Rustom Mody wrote: > On Thursday, March 3, 2016 at 8:11:20 AM UTC+5:30, Terry Reedy wrote: > > On 3/2/2016 10:22 AM, Rustom Mody wrote: > > > On Tuesday, March 1, 2016 at 12:23:02 PM UTC+5:30, Terry Reedy wrote: > > >> On 2/29/2016 7:42 AM, Rustom

Re: Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-03-02 Thread Rustom Mody
On Thursday, March 3, 2016 at 8:11:20 AM UTC+5:30, Terry Reedy wrote: > On 3/2/2016 10:22 AM, Rustom Mody wrote: > > On Tuesday, March 1, 2016 at 12:23:02 PM UTC+5:30, Terry Reedy wrote: > >> On 2/29/2016 7:42 AM, Rustom Mody wrote: > >> > >>> Is import needed at all when trying out in Idle? > >> .

Re: Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-03-02 Thread Terry Reedy
On 3/2/2016 10:22 AM, Rustom Mody wrote: On Tuesday, March 1, 2016 at 12:23:02 PM UTC+5:30, Terry Reedy wrote: On 2/29/2016 7:42 AM, Rustom Mody wrote: Is import needed at all when trying out in Idle? ... So it does appear that 1. import not necessary with(in) idle 2. However import and f5 (

Re: Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-03-02 Thread Rustom Mody
On Tuesday, March 1, 2016 at 12:23:02 PM UTC+5:30, Terry Reedy wrote: > On 2/29/2016 7:42 AM, Rustom Mody wrote: > > > Is import needed at all when trying out in Idle? > ... > > So it does appear that > > 1. import not necessary with(in) idle > > 2. However import and f5 (ie is run as main) are di

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

2016-03-02 Thread Grant Edwards
On 2016-03-02, Ian Kelly wrote: > Software updates? The nice thing about *nix systems is that *most* > updates don't require a reboot. I'm still going to reboot any time > there's a kernel update though, and those are fairly frequent. I could > read the patch notes to determine whether this new k

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

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 3:45:28 PM UTC+5:30, Rustom Mody wrote: > On Wednesday, March 2, 2016 at 7:53:10 AM UTC+5:30, Ian wrote: > > On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote: > > > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > > > > > >> There's a big difference between > > >>

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

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 7:53:10 AM UTC+5:30, Ian wrote: > On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote: > > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > > > >> There's a big difference between > >> that and clocking a year of uptime just because you can, though. > > > > What othe

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

2016-03-01 Thread Ian Kelly
On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote: > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > >> There's a big difference between >> that and clocking a year of uptime just because you can, though. > > What other reason is there for having a year of uptime? > > It's not like it is diffi

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

2016-03-01 Thread Steven D'Aprano
On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > There's a big difference between > that and clocking a year of uptime just because you can, though. What other reason is there for having a year of uptime? It's not like it is difficult. My laptop doesn't actually go anywhere: for historical reason

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

2016-03-01 Thread Chris Angelico
On Wed, Mar 2, 2016 at 9:29 AM, Ian Kelly wrote: > I certainly understand the value of being able to work on a mudlib > without having to restart the mud. There's a big difference between > that and clocking a year of uptime just because you can, though. Oh, sure. I mentioned the year because I h

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

2016-03-01 Thread Ian Kelly
On Tue, Mar 1, 2016 at 3:02 PM, Chris Angelico wrote: > On Wed, Mar 2, 2016 at 8:53 AM, Ian Kelly wrote: >> I have a hard time understanding the appeal of super-long uptimes. I'm not >> even comfortable running a single kernel version that long. What's so awful >> about 5 minutes of announced dow

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

2016-03-01 Thread Chris Angelico
On Wed, Mar 2, 2016 at 8:53 AM, Ian Kelly wrote: > On Mar 1, 2016 4:41 AM, "Chris Angelico" wrote: >> >> On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano > wrote: >> > I cannot imagine why you would want to reload() in production code. That >> > would imply that your production code is modifying

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

2016-03-01 Thread Ian Kelly
On Mar 1, 2016 4:41 AM, "Chris Angelico" wrote: > > On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano 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

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

2016-03-01 Thread Chris Angelico
On Wed, Mar 2, 2016 at 4:11 AM, Steven D'Aprano wrote: > On Tue, 1 Mar 2016 10:39 pm, Chris Angelico wrote: > >> On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano >> wrote: >>> I cannot imagine why you would want to reload() in production code. That >>> would imply that your production code is mod

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

2016-03-01 Thread Steven D'Aprano
On Tue, 1 Mar 2016 10:39 pm, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano > 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

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

2016-03-01 Thread Steven D'Aprano
On Tue, 1 Mar 2016 12:25 am, alien2u...@gmail.com wrote: >> 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 There are better ways to manage your

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

2016-03-01 Thread Chris Angelico
On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano 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? Pos

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

2016-03-01 Thread Steven D'Aprano
On Mon, 29 Feb 2016 06:01 pm, Chris Angelico wrote: > I've never used reload() in any production code, ever. Ever. reload() isn't intended for production code. It is a convenience for interactive use. I cannot imagine why you would want to reload() in production code. That would imply that your

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

2016-02-29 Thread Terry Reedy
On 2/29/2016 8:22 AM, alien2u...@gmail.com wrote: Hello Rustom, F5 in Idle restarts the Python interpreter (that's what my impression is). More exactly, IDLE runs user code in a separate process from the one that runs the IDLE gui. Restarting means that the existing user process is terminat

Re: Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-02-29 Thread Terry Reedy
On 2/29/2016 7:42 AM, Rustom Mody wrote: Is import needed at all when trying out in Idle? ... So it does appear that 1. import not necessary with(in) idle 2. However import and f5 (ie is run as main) are different May some idle experts elaborate on this? Whats the idle idiom of import-ing?

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

2016-02-29 Thread Chris Angelico
On Tue, Mar 1, 2016 at 2:33 AM, BartC wrote: >> I think the OP's talking more about the situation of having an active >> session (IDLE was mentioned), importing a local module (a .py file >> from the current directory), then editing the file and re-importing, >> which has no effect. While I am sym

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

2016-02-29 Thread BartC
On 29/02/2016 07:11, Chris Angelico wrote: On Mon, Feb 29, 2016 at 6:02 PM, Ian Kelly wrote: - 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. Because there are legitimate reasons fo

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

Reason for not allowing import twice but allowing reload()

2016-02-29 Thread Rustom Mody
On Monday, February 29, 2016 at 6:53:09 PM UTC+5:30, alien...@gmail.com wrote: > 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

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

Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-02-29 Thread Rustom Mody
On Monday, February 29, 2016 at 12:10:28 PM UTC+5:30, alien2utoo wrote: > 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,

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

2016-02-28 Thread Chris Angelico
On Mon, Feb 29, 2016 at 6:02 PM, Ian Kelly wrote: >> - 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. > > Because there are legitimate reasons for importing the same module > mult

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

2016-02-28 Thread Ian Kelly
On Sun, Feb 28, 2016 at 11:40 PM, wrote: > 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 rel

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

2016-02-28 Thread Chris Angelico
On Mon, Feb 29, 2016 at 5:40 PM, wrote: > 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 coul

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