[Tutor] Verifying My Troublesome Linkage Claim between Python andWin7

Alan Gauld alan.gauld at btinternet.com
Wed Feb 24 10:23:31 CET 2010


"Wayne Watson" <sierra_mtnview at sbcglobal.net> wrote

> My claim is that if one creates a program in a folder that reads a file 
> in the folder it and then copies it to another folder, it will read  the 
> data file in the first folder, and not a changed file in the new folder.

Thats what I would expect in any OS.
Unless you explicitly change the folder name the program will
still be using the original file. You would need to explicitly tell
Python to open the new copied file.

> My experience is that if one checks the properties of the copied file, it 
> will point to the original py file and execute it and not the copy.

OK, Now I'm confused. If you copied the file it should not reference the 
original.
How are you copying it? Are you using shutil.copy()?

> If win7 is the culprit, I would think this is a somewhat  serious 
> problem.

It seems unlikely to be W7.

> It may be the sample program is not representative of the larger program 
> that has me stuck. If necessary I can provide it. It uses common modules. 
> (Could this be something like the namespace usage of variables that share 
> a common value?)

No idea, please post it if it is reasonably short.
Working from code is always more precise than from text descriptions.

> # To verify my situation use IDLE, save and run this program there.
> # Put this program into a folder along with a data file
> # called verify.txt. Create a single text line with a few characters in 
> it
> # Run this program and note the output
> # Copy the program and txt file to another folder
> # Change the contents of the txt file
> # Run it again, and see if the output is the same as in the other folder
> track_file = open("verify.txt")
> aline = track_file.readline();
> print aline
> track_file.close()

OK, This is not what I thought you meant from your description!
You are copying the files as a user.
How are you doing that?
- from a command window?
- Or using Windows Explorer?
- Using drag n drop or copy/paste?
Still a lot of variables.

What happens if you run the program from the command line rather than IDLE?
Did you close and restart IDLE between runs?

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list