David Smith <dav...@invtools.com> wrote: > >I'm converting windows bat files little by little to Python 3 as I find >time and learn Python. >The most efficient method for some lines is to call Python like: >python -c "import sys; sys.exit(3)" > >How do I "indent" if I have something like: >if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else >sys.exit(3) > >My sole result in many attempts is "Syntax Error."
The other responses asking "why" are excellent, but this will do that specific job: sys.exit( {'Cope':1,'Perform':2}.get(sR,3) ) The best way to convert a batch file to Python is to convert the whole file to a Python script. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list