[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Verifying My Troublesome Linkage Claim between Python and Win7

W. eWatson

2/23/2010 1:03:00 PM

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()
10 Answers

rpdooling

2/23/2010 4:26:00 PM

0

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...

RD

W. eWatson

2/23/2010 6:12:00 PM

0

On 2/23/2010 8:26 AM, Rick Dooling wrote:
> 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...
>
> 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.

Gib Bogle

2/23/2010 7:08:00 PM

0

Rick Dooling wrote:
> No telling what Windows will do. :)

It isn't useful to respond to a serious question with OS bigotry.

Gib Bogle

2/23/2010 7:14:00 PM

0

W. eWatson wrote:
> On 2/23/2010 8:26 AM, Rick Dooling wrote:
>> 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...
>>
>> 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.

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

W. eWatson

2/23/2010 9:00:00 PM

0

On 2/23/2010 11:14 AM, Gib Bogle wrote:
> W. eWatson wrote:
>> On 2/23/2010 8:26 AM, Rick Dooling wrote:
>>> 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...
>>>
>>> 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.
>
> How do you invoke the program? Do you use a Command Prompt window?
IDLE, but I'm prett sure I tried it (300 lines) with Cprompt.

Gib Bogle

2/23/2010 9:29:00 PM

0

W. eWatson wrote:
> On 2/23/2010 11:14 AM, Gib Bogle wrote:
>> W. eWatson wrote:
>>> On 2/23/2010 8:26 AM, Rick Dooling wrote:
>>>> 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...
>>>>
>>>> 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.
>>
>> How do you invoke the program? Do you use a Command Prompt window?
> 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
?

aahz

2/24/2010 2:05:00 AM

0

In article <hm0jn4$tnf$1@news.eternal-september.org>,
W. eWatson <wolftracks@invalid.com> 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.
>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 (aahz@pythoncraft.com) <*> http://www.python...

"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

rpdooling

2/24/2010 3:53:00 AM

0

On Feb 23, 1:08 pm, Gib Bogle <g.bo...@auckland.no.spam.ac.nz> wrote:

> It isn't useful to respond to a serious question with OS bigotry.

Okay, I'll go with what Aahz said:

> I've seen similar issues on Win7.
> AFAIK, this has nothing to do with Python.

W. eWatson

3/1/2010 5:50:00 PM

0

On 2/23/2010 6:04 PM, Aahz wrote:
> In article<hm0jn4$tnf$1@news.eternal-september.org>,
> W. eWatson<wolftracks@invalid.com> 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.
>> 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.
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.

alex23

3/2/2010 12:50:00 PM

0

"W. eWatson" <wolftra...@invalid.com> 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.
> 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.