[GRASS-dev] Re: [GRASSGUI] silly question - running a python script

Glynn Clements glynn at gclements.plus.com
Sun Jun 10 16:46:27 EDT 2007


Glynn Clements wrote:

> Although the "try ... except IndexError" can be replaced with a length
> check on sys.argv, i.e.:
> 
>     if __name__ == "__main__":
>         if ( len(sys.argv) > 1 && sys.argv[1] != "@ARGS_PARSED@" ):
>             os.execv("g.parser", [sys.argv[0]] + sys.argv)
> 	else:
>             main()

Correction:

	if __name__ == "__main__":
	    if ( len(sys.argv) <= 1 or sys.argv[1] != "@ARGS_PARSED@" ):
	        os.execvp("g.parser", [sys.argv[0]] + sys.argv)
	    else:
	        main();

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list