python - How can it be that len(sys.argv) <= 0? -


in code, following error triggered, , not understand how case can come up:

if(len(sys.argv) > 0):     dosomething() else:     raise attributeerror("could not parse script name") 

the above code in python class, import , use in script. use same class same call in other scripts, , works fine everywhere else. fyi, os ubuntu.

how possible len(sys.argv) <= 0?

ok, found answer; @nneonneo gave right hint, @ point argv modified:

args = sys.argv del args[0] 

i guess author of code wanted different, because deletes sys.argv[0]. looking change in following way:

args = sys.argv[1:] 

thank you!


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -