SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

How To Pass Command Line Arguments IronPython

Last post 10-17-2012 8:01 PM by MattWard. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-16-2012 4:15 AM

    How To Pass Command Line Arguments IronPython

    Hi, I am new to ironpython and sharpdevelop and I am trying to run the following code,

     

    from sys import argv

    script, first, second, third = argv

    print "The script is called:", script
    print "Your first variable is:", first
    print "Your second variable is:", second
    print "Your third variable is:", third

     

    How do I pass the arguments to the command line ?

     

    Thanks.

  • 10-16-2012 8:36 PM In reply to

    Re: How To Pass Command Line Arguments IronPython

    You can either go into project options (Project - Project Options) and then select the Debug tab. Here you can change the command line arguments (e.g. "-X:Debug Program.py foo bar a b c")

    Alternatively you can run your program from the command line. If you take the path from the Start external program in the Debug tab that will give you the path to ipy.exe, IronPython's interpreter. Then use the command line arguments as described in the previous step.

    I could not get your code to work but the following works with the command line arguments set in project options.

    from sys import argv

    print len(argv)

    #script, first, second, third = argv

    print "The script is called:", argv[0]
    print "Your first variable is:", argv[1]
    print "Your second variable is:", argv[2]

    from System import Console
    Console.ReadKey()

  • 10-16-2012 11:26 PM In reply to

    Re: How To Pass Command Line Arguments IronPython

    Iset the arguements in the debug tab but it still didnt work. I got the error that I need more than one values to unpack.

  • 10-17-2012 7:53 PM In reply to

    Re: How To Pass Command Line Arguments IronPython

    That is an error in your code not with the command line arguments being passed to your application.

  • 10-17-2012 8:01 PM In reply to

    Re: How To Pass Command Line Arguments IronPython

    Actually your code is fine as long as you pass the correct amount of arguments on the command line. My command line is "-X:Debug Program.py a b c" without the quotes.

Page 1 of 1 (5 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.