"Leif K-Brooks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [EMAIL PROTECTED] wrote: >> I'm trying to get this bit of code to work without triggering the >> IndexError. >> >> import shutil, os, sys >> >> if sys.argv[1] != None: >> ver = sys.argv[1] >> else: >> ver = '2.14' > > Catch it: > > try: > ver = sys.argv[1] > except IndexError: > ver = '2.14'
Or slice it: if sys.argv[1:2] != []: <etc> tjr -- http://mail.python.org/mailman/listinfo/python-list