Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python 3 minor irritation

Reply
Thread Tools

Python 3 minor irritation

 
 
Gib Bogle
Guest
Posts: n/a
 
      02-05-2010
Gabriel Genellina wrote:

> Sorry, I should have removed that line. This is just my setup; a normal
> Python install doesn't create that registry entry. It allows Desktop
> Search (or Windows Search, or whatever it is called nowadays; the F3
> key) to search inside .py files (default behavior is to just ignore
> their contents).
> See http://support.microsoft.com/kb/309173
>
>> Is this related to the fact that when I double-click on a .py file the
>> command window disappears after the execution is completed?

>
> (I bet the "Persistent" word confused you.) No, as you can see, it's
> completely unrelated. AFAIK, there is no way (on XP and later at least)
> to keep a console window open after the program exited. Three choices:
>
> - Open a cmd window and execute the script there. You may drag&drop the
> file over the window to avoid typing the full path (I think this last
> part does not work on Vista nor Win7)
>
> - Add a raw_input() [2.x] or input() [3.x] line at the end of the script
>
> - Rename it with a '.cmd' extension and add this line at the very top:
>
> @(C:\Python26\Python -x %~f0 %* || pause) && goto:EOF
>
> (see this post by Duncan Booth last month:
> http://comments.gmane.org/gmane.comp...general/650913 )
>


Thanks Gabriel. I didn't know about the drag&drop capability (learn something
every day, forget two things). BTW input() works for me in 2.5.
Cheers
Gib
 
Reply With Quote
 
 
 
 
David Monaghan
Guest
Posts: n/a
 
      02-05-2010
On Thu, 04 Feb 2010 00:39:01 +0000, David Monaghan
<(E-Mail Removed)> wrote:

>I have a small program which reads files from the directory in which it
>resides. It's written in Python 3 and when run through IDLE or PythonWin
>works fine. If I double-click the file, it works fine in Python 2.6, but in
>3 it fails because it looks for the files to load in the Python31 folder,
>not the one the script is in.
>
>It's not a big deal, but browsing around I haven't found why the behaviour
>has been changed or any comment about it (That might be my poor search
>technique, I suppose).
>
>The program fails at:
>
> try:
> tutdoc = minidom.parse(".//Myfile.xml")
> except IOError:
> <snip>


I very much appreciate all the help offered on this, but feel a bit of an
idiot now as I can't reproduce the behaviour (it had happened on two
separate machines).

What I am still getting is a similar problem on my work computer with the
program on a network hard drive. Not always - it'll run on repeated
attempts, then fail for a few, then work again. When it failed I ran the
script as suggested:

import os
print("curdir=", os.getcwd())
print("__file__=", __file__)
input()

and got the response:

curdir= H:\
__file__= H:\FRCR\FRCR2010\Course documents\FRCR2009\Script1.py

so it's 'sticking' at H:

For interest, I ran the script from IDLE, too, and PythonWin, on three
separate computers (2 Python3, 1 Python2.6)

With that I get a NameError for __file__

curdir= H:\FRCR\FRCR2010\Course documents\FRCR2009
Traceback (most recent call last):
File "H:\FRCR\FRCR2010\Course documents\FRCR2009\Script1.py", line 3,
in <module>
print("__file__=", __file__)
NameError: name '__file__' is not defined

What have I done wrong?

DaveM
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: Thursday Irritation CBIC MCSE 6 09-29-2006 06:55 PM
Irritation larry Computer Support 1 09-09-2005 07:14 PM
Minor irritation: Can't delete the IE Links folder edgy Computer Support 4 10-29-2004 11:07 AM
debugger restarted stops in javascript, minor irritation foldface@yahoo.co.uk ASP .Net 0 06-11-2004 02:26 PM
MGM - another P&S irritation karlpov DVD Video 11 12-28-2003 11:47 PM



Advertisments