By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,089 Members | 2,418 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,089 IT Pros & Developers. It's quick & easy.

file Error

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.