Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Alan Gauld

> Why did I get this diagnostic?

 import factor30.py
> ImportError: No module named factor30.py

The module name is factor30

no need for the .py, thats the file name. Two differemt things!

Alan g.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread John Fouhy
On 20/02/06, Kermit Rose <[EMAIL PROTECTED]> wrote:
> >>> import factor30.py
>
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> import factor30.py
> ImportError: No module named factor30.py

Because the module is named 'factor30', not 'factor30.py' ...

--
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Kermit Rose






 
 

From: Alan Gauld
Date: 02/19/06 19:55:13
To: Kermit Rose
Cc: Python Tutor list
Subject: Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?
 
Restoring the tutor list on CC
 
**
 
Thanks for reminding me.
 
 
Assuming Windows NT/2000/XP you go to My Computer and right click
Select Properties and go to the Advanced tab
 
Click Environment Variables button
 
Under System Variables click New
In Varable Name type PYTHONPATH
in upper case
 
In variable value type your folder name
 
c:\math\factoring
 
 
I saw the PYTHONPATH name being added to the variable list.
 
how might I verify, after the fact, that the name is correct?
 

 
I did all that.
 
Why did I get this diagnostic?
 
>>> import factor30.py
 
Traceback (most recent call last):  File "", line 1, in -toplevel-    import factor30.pyImportError: No module named factor30.py
 
 
 
 







___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Alan Gauld
Restoring the tutor list on CC

- Original Message - 
From: "Kermit Rose" <[EMAIL PROTECTED]>
To: "Alan Gauld" <[EMAIL PROTECTED]>


> How can I add "c:\math\factoring" to the PYTHONPATH?

What OS are you using?
Assuming Windows NT/2000/XP you go to My Computer and right click
Select Properties and go to the Advanced tab

Click Environment Variables button

Under System Variables click New
In Varable Name type PYTHONPATH
in upper case

In variable value type your folder name

c:\math\factoring

in this case


> is 
>
> reload(foo)
>
> equivalent to
>
> import foo

More or less, yes. There may be a few subtle differences but if so I don't 
know what they are! Except you can only reload *after* using an import.
And using import twice will not reload the module.

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Alan Gauld
>>> import "c:\\math\\factoring\\factor30.py"

Just use

>>> import factor30

the file will need to be in Pythons search path.

The easiest way is to use a single folder for all your code.

the folder called site-packages should be included by default 
so you might like to use that. Alternatively you can use another 
one and add that folder to an environment vartiable 
called PYTHONPATH

> Could you explain this more.   I'm not compiling or recompiling 
> the function subroutine.

Actually you are. When python imports a file (foo.py say) it compiles 
it into bytecode (and creates a file called foo.pyc in the process).

Reload makes sure you get the latest updated version.

reload(foo)

Alan G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor