Two Simple Qs: 
Author Message
 Two Simple Qs:

I am quite new to python. I have 2 simple questions:

1. How can I run a simply python script under IDLE directly? I wrote a
start.py to do some routine work, like importing some medules and
adding my working path into sys.path, before I start to work. This
script is just like a macro or batch file under DOS. Now I have to
open this file and then run it. I hope python have a statement can run
it directly( maybe like 'run start.py').

2. When I made some modification of my own module after I import this
module,python can not recognized the modified module even I import it
again. It raised the same error msg, but gave me the error line
actually I have corrected, that is , it run as the old module but
display the error from the newer module file. I have to restart python
environment and import again, then my module run correctly. Is this a
bug? And how to resolve it?

Thank you.

Newgene



Sun, 04 Jan 2004 02:19:51 GMT  
 Two Simple Qs:

Quote:

> 1. How can I run a simply Python script under IDLE directly?

Under the "Edit" menu, you'll find a "Run Script" option. You can do
the "Run Script" thing directly by hitting Control-F5. This works from
the Editor window (where you are editing your script) but it doesn't
work from the "*Python Shell*" window.

Quote:
> 2. When I made some modification of my own module after I import this
> module,python can not recognized the modified module even I import it
> again.

After you do "import mymodule" and then later make changes in mymodule.py,
type "reload(mymodule)" to pick up the changes. Be sure to save the file
first, but IDLE should warn you if you've forgotten to save it.

--
-----------------------------------+---------------------
 22nd century: Esperanto, geodesic | Will Ware



Sun, 04 Jan 2004 02:41:32 GMT  
 Two Simple Qs:

Quote:

> I am quite new to python. I have 2 simple questions:

> 1. How can I run a simply Python script under IDLE directly? I wrote a
> start.py to do some routine work, like importing some medules and
> adding my working path into sys.path, before I start to work. This
> script is just like a macro or batch file under DOS. Now I have to
> open this file and then run it. I hope python have a statement can run
> it directly( maybe like 'run start.py').

try "import start.py"

Quote:
> 2. When I made some modification of my own module after I import this
> module,python can not recognized the modified module even I import it
> again. It raised the same error msg, but gave me the error line
> actually I have corrected, that is , it run as the old module but
> display the error from the newer module file. I have to restart python
> environment and import again, then my module run correctly. Is this a
> bug? And how to resolve it?

Not quite clear what you're asking here, but try "reload(myModule)"

hth,
-- bjorn



Sun, 04 Jan 2004 02:37:39 GMT  
 Two Simple Qs:

comp.lang.python in article

:I am quite new to python. I have 2 simple questions:
:
:1. How can I run a simply Python script under IDLE directly? I wrote a
:start.py to do some routine work, like importing some medules and
:adding my working path into sys.path, before I start to work. This
:script is just like a macro or batch file under DOS. Now I have to
:open this file and then run it. I hope python have a statement can run
:it directly( maybe like 'run start.py').

To run a script from within IDLE:
1. Go to the File menu and choose "Open". Browse to your script and
select it. It should open in a new window.
2. In this new window, go to the Edit menu and select "Run Script". The
output of your script will appear in the Interactive Python Shell (the
original IDLE window that you had open).

:2. When I made some modification of my own module after I import this
:module,python can not recognized the modified module even I import it
:again. It raised the same error msg, but gave me the error line
:actually I have corrected, that is , it run as the old module but
:display the error from the newer module file. I have to restart python
:environment and import again, then my module run correctly. Is this a
:bug? And how to resolve it?

Try this:

Quote:
>>> del modulename
>>> import modulename

Hopefully that will help.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



Sun, 04 Jan 2004 03:33:43 GMT  
 Two Simple Qs:
Thank you all!

Now I got the solutions for both Qs.

Newgene



Sun, 04 Jan 2004 22:49:09 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Two simple (I hope) QS about grid

2. two Qs from a nubie

3. Few simple qs

4. Simple Qs: Do I need to uninstall before install

5. read two sets of data from two spread sheet files to two arrays problem

6. Two simple questions

7. Two simple browse to report questions

8. Two simple questions

9. Two simple questions (hopefully)

10. two simple questions

11. two simple Gofer questions

12. I need two, hopefully simple, questions answered.

 

 
Powered by phpBB® Forum Software