Hi there,
I had a quick question on the Textmate "Python -> Run Script" command. Since I mostly write command line utilities, I pass command line arguments to my scripts on a regular basis.
Is there a way to test your python script (CMD-R) and have Textmate populate sys.argv[:] for the script to use? Either via a dialog box, a TM Variable, etc?
Thanks for any help,
---- Brian H binarynomad@gmail.com http://www.binarynomad.com
What I do is test for TM_APP_PATH in os.environ:
import os
if __name__ == '__main__': if 'TM_APP_PATH' in os.environ: print 'Hello Textmate!' else: print 'Hello Terminal!'
If you are working in a project, you could set your own environment variable for the project and test for it instead:
import os import sys
if __name__ == '__main__': if 'PY_ARGV' in os.environ: argv = os.environ.get('PY_ARGV').split() else: argv = sys.argv[1:] do_something_with(argv)
On Mon, May 31, 2010 at 9:08 PM, Brian H binarynomad@gmail.com wrote:
Hi there,
I had a quick question on the Textmate "Python -> Run Script" command. Since I mostly write command line utilities, I pass command line arguments to my scripts on a regular basis.
Is there a way to test your python script (CMD-R) and have Textmate populate sys.argv[:] for the script to use? Either via a dialog box, a TM Variable, etc?
Thanks for any help,
Brian H binarynomad@gmail.com http://www.binarynomad.com
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 1 Jun 2010, at 02:08, Brian H wrote:
Is there a way to test your python script (CMD-R) and have Textmate populate sys.argv[:] for the script to use? Either via a dialog box, a TM Variable, etc?
Don't know how it works over in python land, but when I'm doing the same with ruby scripts I tend to just assign ARGV manually and put up with a warning whilst I'm writing it. Something like this at the top of the script before I process ARGV:
ARGV = %w(--help)
C --- Caius Durling caius@caius.name +44 (0) 7960 268 100 http://caius.name/