469,363 Members | 2,566 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,363 developers. It's quick & easy.

file Error

Hi,
I am parsing an xml file,and using raw_input command to ask the
user to enter the file name.Ex
>>>
Enter The ODX File Path:

Suppose my code does not work properly,then in the python idle window
it shows something like this:
>>>
C:\Projects\ODX Import\Sample Files\MiscFiles
\CIM_A3300_diag_spec_sw49.xml
Traceback (most recent call last):
File "C:\Projects\ODX Import\code_ini\odxparse_mod_off_comm.py",
line 339, in <module>
process_variant(variant)
File "C:\Projects\ODX Import\code_ini\odxparse_mod_off_comm.py",
line 285, in process_variant
triplet = triplet + get_did_lengths(iservice,local_service_id)
File "C:\Projects\ODX Import\code_ini\odxparse_mod_off_comm.py",
line 238, in get_did_lengths
local_min = local_min + ddoref_min[ddorefstring]
KeyError: '_210'

This is some bug related to code ..thats ok..but when i run
the program immediately again for some other input..then it does not
show the prompt :
>>>
Enter The ODX File Path:

but instead a blinking prompt which accepts the
filename something like this:
>>>
C:\Projects\ODX Import\Sample Files\MiscFiles\Diagnostic CTS Global
Epsilon TIM V1.4.xml

I want the inputfile prompt to appear regardless of
the error condition.I dont know where the problem lies.Can someone
help me out.
Thanks

May 3 '07 #1
3 950
En Thu, 03 May 2007 09:39:37 -0300, <sa**********@gmail.comescribió:
Hi,
I am parsing an xml file,and using raw_input command to ask the
user to enter the file name.Ex
>>>>
Enter The ODX File Path:

Suppose my code does not work properly,then in the python idle window
it shows something like this:
[...traceback...]
I want the inputfile prompt to appear regardless of
the error condition.I dont know where the problem lies.Can someone
help me out.
- IDLE is a development environment - don't use it to actually run your
program in production.

- Instead of asking the user to type the file name, accept it as a
parameter, that's what almost everyone else does in the world... It has
many advantages: you can associate your program with the filename
extension, you can use the "Send to..." menu, you can run it inside a
batch file, you can drop a file over your program to be processed, etc.

--
Gabriel Genellina
May 3 '07 #2
On May 3, 6:09 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Thu, 03 May 2007 09:39:37 -0300, <saif.shak...@gmail.comescribió:
Hi,
I am parsing an xml file,and using raw_input command to ask the
user to enter the file name.Ex
Enter The ODX File Path:
Suppose my code does not work properly,then in the python idle window
it shows something like this:
[...traceback...]
I want the inputfile prompt to appear regardless of
the error condition.I dont know where the problem lies.Can someone
help me out.

- IDLE is a development environment - don't use it to actually run your
program in production.

- Instead of asking the user to type the file name, accept it as a
parameter, that's what almost everyone else does in the world... It has
many advantages: you can associate your program with the filename
extension, you can use the "Send to..." menu, you can run it inside a
batch file, you can drop a file over your program to be processed, etc.

--
Gabriel Genellina
Thanks for the reply........How do i accept the filename is a
parameter and avoid the error.Can you elaborate.

May 3 '07 #3
En Thu, 03 May 2007 10:15:52 -0300, <sa**********@gmail.comescribió:
Thanks for the reply........How do i accept the filename is a
parameter and avoid the error.Can you elaborate.
To get the arguments passed to the script, use sys.argv[]
Most introductory texts should cover it, like the Python tutorial:
http://docs.python.org/tut/node4.html

--
Gabriel Genellina
May 4 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Hans-Joachim Widmaier | last post: by
1 post views Thread by jase_dukerider | last post: by
7 posts views Thread by Mark | last post: by
6 posts views Thread by tshad | last post: by
2 posts views Thread by Dan | last post: by
68 posts views Thread by Martin Joergensen | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.