Verifying My Troublesome Linkage Claim between Python and Win7

W

W. eWatson

In the last day, I posted a message titled "What's Going on between
Python and win7?" I'd appreciate it if someone could verify my claim. A
sample program to do this is below. I'm using IDLE in Win7 with Py 2.5.

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.
I'd appreciate it if some w7 users could try this, and let me know what
they find.

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.


# Test program. Examine strange link in Python under Win7
# when copying py file to another folder.
# Call the program vefifywin7.py
# 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 if 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()
 
W

W. eWatson

No telling what Windows will do. :)

I am a mere hobbyist programmer, but I think real programmers will
tell you that it is a bad habit to use relative paths. Use absolute
paths instead and remove all doubt.

http://docs.python.org/library/os.path.html

RD
You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.
 
G

Gib Bogle

W. eWatson said:
You may be right. The actual 300 line program just reads the folder
without specifying any path. I'm not that familiar with os path, but
have seen it used.

How do you invoke the program? Do you use a Command Prompt window?
 
G

Gib Bogle

W. eWatson said:
IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.

I don't know what you mean by "300 lines". Have you opened a Command Prompt
window, changed to the directory where you copied the files, and executed:
python your_prog.py
?
 
A

Aahz

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.
I'd appreciate it if some w7 users could try this, and let me know what
they find.

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.

I've no time to verify your specific claim and have no readily available
proof for mine, but I've seen similar issues on Win7. AFAIK, this has
nothing to do with Python.
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
 
W

W. eWatson

I've no time to verify your specific claim and have no readily available
proof for mine, but I've seen similar issues on Win7. AFAIK, this has
nothing to do with Python.
I've been away for several days and have no idea if anyone above figured
this out. Likely not,since your post is at the end.

Interesting about 'similar'. I'm pretty much done exploring every nook
and cranny on this problem. It can be worked around. I will say that if
I look at the properties of the copied file, it shows a shortcut tab
that leads back to the original file. I have no recollection of making a
shortcut, and always use Copy and Paste. Further, if I do create
shortcut in W7, it adds "-shortcut to the file suffix. I do not ever
recall seeing that anywhere. I just tried it in XP, and it puts it in
front of the name.
 
A

alex23

W. eWatson said:
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.
I'd appreciate it if some w7 users could try this, and let me know what
they find.

On a fresh install of Win7 Ultimate, I created your program & the text
file in one folder, then copied the program both using ctrl-c/ctrl-v
and later ctrl-drag-&-drop. In both cases, the copied program *did
not* refer to the text file when executed:

D:\projects>a
Traceback (most recent call last):
File "D:\projects\a.py", line 1, in <module>
track_file = open("verify.txt")
IOError: [Errno 2] No such file or directory: 'verify.txt'

Whatever you seem to think you did, you didn't, or you're not
providing enough detail on what you did to repeat the behaviour.

I do agree with the sentiment that this isn't a Python issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top