[IronPython] Two Problems with sys.argv and compiled scripts

Michael Foord fuzzyman at voidspace.org.uk
Mon Mar 23 22:16:58 CET 2009


Bruce Bromberek wrote:
> Problem #1
> I know this is a know issue, but my google-fu has been able to uncover 
> the solution.  When I compile my script into an exe , sys.argv get 
> sets to ' '.
>
> Using SharpDevelop and Ironpython 2.0.1
>
> #Program.py
> #
> import clr
> clr.AddReference('mscorlib')
> clr.AddReference('System')
> import sys
> import System
>
> if __name__ == 'Program':
>     try:
>         print "sys.argv = ",sys.argv
>     except System.Exception, e:
>         print e
>
> yeilds output of
> C:\Program Files\IronPython 2.0.1\Samples\pyc>Program.exe fred
> sys.argv =  ['']
>
> instead of the expected
> sys.argv['fred']
>
> Problem #2:
>
> If I drag and drop a file onto the exe, I get a exception message that 
> I can't see.  In IronPython 1.0, the dropped file would populate sys.argv
>
> Hopefully someone can answer or direct me to better source.


Creating a custom C# executable that embeds the IronPython engine, 
starts your application, and populates sys.argv is the best workaround 
for these problems.

Michael

>
> -WombatPM
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog





More information about the Ironpython-users mailing list