Created
November 15, 2012 09:49
-
-
Save ythuang/4077729 to your computer and use it in GitHub Desktop.
Sublime Text 2's snippet to create Python skeleton script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Sublime Text 2's snippet to create Python skeleton script. | |
Put this file `$HOME/Library/Application Support/Sublime Text 2/Packages/User` directory. | |
To activate, type `python` and followed by <TAB> (maybe twice pressing the <TAB> if your default file syntax is `Plain Text`.) | |
--> | |
<snippet> | |
<content><![CDATA[ | |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import argparse | |
import traceback | |
def main(): | |
parser = argparse.ArgumentParser(description='Booyakasha!') | |
parser.add_argument('-F', '--foo', required=True, help='foo') | |
parser.add_argument('-B', '--bar', help='bar') | |
args = parser.parse_args() | |
print args.foo, | |
if args.bar: | |
print args.bar | |
if __name__ == '__main__': | |
try: | |
main() | |
sys.exit(0) | |
except KeyboardInterrupt, e: | |
raise e | |
except SystemExit, e: | |
raise e | |
except Exception, e: | |
print str(e) | |
traceback.print_exc() | |
sys.exit(1) | |
]]></content> | |
<tabTrigger>python</tabTrigger> | |
<scope></scope> | |
<description>Python skeleton script with args</description> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment