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