summaryrefslogtreecommitdiff
path: root/snippets/python.json
blob: 215c633f7ab2dc197b87d548788bd32ac80b6946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
	// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	//
	// You can also restrict snippets to specific files using include/exclude patterns:
	// "Test snippet": {
	// 	"prefix": "test",
	// 	"body": "test('$1', () => {\n\t$0\n});",
	// 	"include": ["**/*.test.ts", "*.spec.ts"],
	// 	"exclude": ["**/temp/*.ts"],
	// 	"description": "Insert test block"
	// }

    "#!": {
        "prefix": "#!",
        "body": "#!/usr/bin/env python"
    },
    "False": {
        "prefix": "f",
        "body": "False$0"
    },
    "None": {
        "prefix": "N",
        "body": "None$0"
    },
    "True": {
        "prefix": "t",
        "body": "True$0"
    },
    "assert": {
        "prefix": "ass",
        "body": "assert $0"
    },
    "doc": {
        "prefix": "d",
        "body": "\"\"\"$0\n\"\"\"\n"
    },
    "docstring_oneliner": {
        "prefix": "do",
        "body": "\"\"\"$0\"\"\""
    },
    "docstring_param": {
        "prefix": "Par",
        "body": ":param $1: $0\n:type $1: "
    },
    "docstring_return": {
        "prefix": "Ret",
        "body": ":return: $0\n:rtype: "
    },
    "dunder": {
        "prefix": "dd",
        "body": "__${name}__$0"
    },
    "enc": {
        "prefix": "enc",
        "body": "# -*- coding: utf-8 -*-\n"
    },
    "ifmain": {
        "prefix": "ifm",
        "body": "if __name__ == '__main__':\n    ${1:main()}"
    },
    "lambda": {
        "prefix": "lam",
        "body": "lambda ${1:x}: $0"
    },
    "not_impl": {
        "prefix": "ni",
        "body": "raise NotImplementedError"
    },
    "print": {
        "prefix": "p",
        "body": "print('$0')"
    },
    "printf": {
        "prefix": "pf",
        "body": "print(f'$0')"
    },
    "property": {
        "prefix": "@",
        "body": "@property\n$0"
    },
    "property_getter": {
        "prefix": "pg",
        "body": "@property\ndef ${1:name}(self):\n    \"\"\"$1-property\"\"\"\n    return self._${1}\n$0"
    },
    "property_setter": {
        "prefix": "ps",
        "body": "@property\ndef ${1:name}(self):\n    \"\"\"$1-property\"\"\"\n    return self._${1}\n\n@$1.setter\ndef $1(self, value):\n    \"\"\"$1-property setter\"\"\"\n    self._$1 = value\n$0"
    },
    "return": {
        "prefix": "r",
        "body": "return $0"
    },
    "script": {
        "prefix": "script",
        "body": "#!/usr/bin/env python\n\n\ndef main(inargs=None):\n    \"\"\"main entry point\"\"\"\n    $0\n\nif __name__ == '__main__':\n    main()\n"
    },
    "self": {
        "prefix": ".",
        "body": "self.$0"
    },
    "self_without_dot": {
        "prefix": "s",
        "body": "self"
    },
    "selfassign": {
        "prefix": "sn",
        "body": "self._$1 = $1"
    },
    "static": {
        "prefix": "sm",
        "body": "@staticmethod\ndef ${1:func}($0):\n"
    }
}