473,383 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

error while passing in strings from the command-line

hey !
these are the arguments that im passing in my program
Expand|Select|Wrap|Line Numbers
  1. filename = str(sys.argv[1]) 
  2. limit_scenarios = int(sys.argv[2]) 
  3. limit_ages = int(sys.argv[3]) 
  4. limit_hours = int(sys.argv[4]) 
  5.  
but once i run it in dos promt
C:\>python m6_setup_me.py "2001summer.tb1" 10 25 3

this is the error message that i get

Traceback (most recent call last):
File "m6_setup_me.py", line 45, in <module>
limit_scenarios = int(sys.argv[1])
ValueError: invalid literal for int() with base 10: '2001summer.tb1'



i know its a minor error , but im not able to figure out what ... it is
thanks
cheers!
Jun 19 '07 #1
1 1477
Smygis
126 100+
hey !
these are the arguments that im passing in my program
Expand|Select|Wrap|Line Numbers
  1. filename = str(sys.argv[1]) 
  2. limit_scenarios = int(sys.argv[2]) 
  3. limit_ages = int(sys.argv[3]) 
  4. limit_hours = int(sys.argv[4]) 
  5.  
but once i run it in dos promt
C:\>python m6_setup_me.py "2001summer.tb1" 10 25 3

this is the error message that i get

Traceback (most recent call last):
File "m6_setup_me.py", line 45, in <module>
limit_scenarios = int(sys.argv[1])
ValueError: invalid literal for int() with base 10: '2001summer.tb1'



i know its a minor error , but im not able to figure out what ... it is
thanks
cheers!
It shuld work fine. As far as i can see you have misplaced some idexes.
limit_scenarios = int(sys.argv[1]) # sys.argv[2]!

My test:
Expand|Select|Wrap|Line Numbers
  1. smygis@Bob:~/src$ cat test.py 
  2. #!/usr/bin/env python
  3. # coding: UTF-8
  4.  
  5. import sys
  6.  
  7. for i in ((c, sys.argv[c]) for c in xrange(len(sys.argv))):
  8.         print "Arg: %d = %s" % i
  9.  
  10.  
  11. smygis@Bob:~/src$ ./test.py hello 12 3 "hello again"
  12. Arg: 0 = ./test.py
  13. Arg: 1 = hello
  14. Arg: 2 = 12
  15. Arg: 3 = 3
  16. Arg: 4 = hello again
  17. smygis@Bob:~/src$ 
  18.  
Jun 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: eje | last post by:
IsNumeric(value) should return false if value "can not be successfully converted to a Double." Instead I get the following error message: "Input string was not in a correct format." I use the...
5
by: Jack | last post by:
Hi, I need to pass multple variables in a link in order to go to a asp page with the two varables. The following are the values of the variables using response.write: <%'Response.Write Mypage...
5
by: Peter Steele | last post by:
We have an application that when it runs in the IDE in debug mode an unhandled exception is occurring in a system header file associated with STL stirngs. The actual statement that crashes is ...
4
by: TJS | last post by:
trying to get a record count from a stored procedure using a supplied SQL statement Error msg: =========== "The SqlParameterCollection only accepts non-null SqlParameter type objects,not...
3
by: Jim in Arizona | last post by:
I'm doing my best to learn ASPNET from a book devoted to ASPNET 1.0. So far, I haven't run into any problems, until now. This is a simple page that should just show the sql strings created by the...
4
by: sebastian.dau | last post by:
Hello Newsgroup, I have a link error that I did not manage to fix. I basically consume a VC 8.0 C++ dll that exports a class with a method containing CString declaration as follows: class...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
6
by: Andy Baker | last post by:
I am attempting to write a .NET wrapper for a C++ DLL file, but am having problems with passing strings as parameters. How should I be writing my C# function call when the C header file is...
4
by: =?Utf-8?B?UmFqaXYgVmVybWE=?= | last post by:
Hi, I am using .NET 3.5 JSON deserializer. When I am passing my JSON server response to DataContractJsonSerializer, DataContractJsonSerializer ser = new...
6
by: jma | last post by:
Hi all, I want to push some errors on an error stack in my function. The first parameter of the push function is the name of the function where the error occured. For example: int...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.