Skip to content

Commit 2263d16

Browse files
author
¨h3ct0rjs¨
committed
Add descriptions for comprehension.json and base.json :happy:
1 parent 3691d4c commit 2263d16

File tree

2 files changed

+62
-31
lines changed

2 files changed

+62
-31
lines changed

snippets/base.json

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,118 @@
11
{
22
"#!/usr/bin/env python": {
33
"prefix": "env",
4-
"body": "#!/usr/bin/env python\n$0"
4+
"body": "#!/usr/bin/env python\n$0",
5+
"description" : "Adds shebang line for default python interpreter."
56
},
67
"#!/usr/bin/env python3": {
78
"prefix": "env3",
8-
"body": "#!/usr/bin/env python3\n$0"
9+
"body": "#!/usr/bin/env python3\n$0",
10+
"description" : "Adds shebang line for default python 3 interpreter."
911
},
1012
"# -*- coding=utf-8 -*-": {
1113
"prefix": "enc",
12-
"body": "# -*- coding=utf-8 -*-\n$0"
14+
"body": "# -*- coding=utf-8 -*-\n$0",
15+
"description" : "set default python2.x encoding specification to utf-8 as it is mentioned in pep-0263."
1316
},
1417
"# coding=utf-8": {
1518
"prefix": "enco",
16-
"body": "# coding=utf-8\n$0"
19+
"body": "# coding=utf-8\n$0",
20+
"description" : "set default python3 encoding specification to utf-8, by default this is the encoding for python3.x as it is mentioned in pep-3120."
1721
},
1822
"from future import ...": {
1923
"prefix": "fenc",
2024
"body": [
2125
"# -*- coding: utf-8 -*-",
2226
"from __future__ import absolute_import, division, print_function, unicode_literals"
23-
]
27+
],
28+
"description" : "Import future statement definitions for python2.x scripts using utf-8 as encoding."
2429
},
2530
"from future import ... v1": {
2631
"prefix": "fenco",
2732
"body": [
2833
"# coding: utf-8",
2934
"from __future__ import absolute_import, division, print_function, unicode_literals"
30-
]
35+
],
36+
"description" : "Import future statement definitions for python3.x scripts using utf-8 as encoding."
3137
},
3238
"import": {
3339
"prefix": "im",
34-
"body": "import ${1:package/module}$0"
40+
"body": "import ${1:package/module}$0",
41+
"description" : "Import a package or module"
3542
},
3643
"from ... import ...": {
3744
"prefix": "fim",
38-
"body": "from ${1:package/module} import ${2:names}$0"
45+
"body": "from ${1:package/module} import ${2:names}$0",
46+
"description" : "Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table."
3947
},
4048
"New class": {
4149
"prefix": "class",
42-
"body": "class ${1:ClassName}(${2:object}):\n\t\"\"\"${3:docstring for $1.}\"\"\"\n\tdef __init__(self, ${4:arg}):\n\t\t${5:super($1, self).__init__()}\n\t\tself.arg = arg\n\t\t$0"
50+
"body": "class ${1:ClassName}(${2:object}):\n\t\"\"\"${3:docstring for $1.}\"\"\"\n\tdef __init__(self, ${4:arg}):\n\t\t${5:super($1, self).__init__()}\n\t\tself.arg = arg\n\t\t$0",
51+
"description" : "Code snippet for a class definition."
4352
},
4453
"New method": {
4554
"prefix": "defs",
46-
"body": "def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0"
55+
"body": "def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0",
56+
"description" : "Code snippet for a class method definition."
4757
},
4858
"New function": {
4959
"prefix": "def",
50-
"body": "def ${1:fname}(${2:arg}):\n\t${3:pass}$0"
60+
"body": "def ${1:fname}(${2:arg}):\n\t${3:pass}$0",
61+
"description" : "Code snippet for function definition."
5162
},
5263
"New froperty": {
5364
"prefix": "property",
54-
"body": "def ${1:foo}():\n doc = \"${2:The $1 property.}\"\n def fget(self):\n ${3:return self._$1}\n def fset(self, value):\n ${4:self._$1 = value}\n def fdel(self):\n ${5:del self._$1}\n return locals()\n$1 = property(**$1())$0"
65+
"body": "def ${1:foo}():\n doc = \"${2:The $1 property.}\"\n def fget(self):\n ${3:return self._$1}\n def fset(self, value):\n ${4:self._$1 = value}\n def fdel(self):\n ${5:del self._$1}\n return locals()\n$1 = property(**$1())$0",
66+
"description" : ""
5567
},
5668
"if": {
5769
"prefix": "if",
58-
"body": "if ${1:condition}:\n\t${2:pass}$0"
70+
"body": "if ${1:condition}:\n\t${2:pass}$0",
71+
"description" : "Code snippet for the if statement."
5972
},
6073
"for": {
6174
"prefix": "for",
62-
"body": "for ${1:value} in ${2:iterable}:\n\t${3:pass}$0"
75+
"body": "for ${1:value} in ${2:iterable}:\n\t${3:pass}$0",
76+
"description" : "Code snippet to create a for loop structure."
6377
},
6478
"while": {
6579
"prefix": "while",
66-
"body": "while ${1:condition}:\n\t${2:pass}$0"
80+
"body": "while ${1:condition}:\n\t${2:pass}$0",
81+
"description" : "Code snippet to create a while loop structure."
6782
},
6883
"try:except:": {
6984
"prefix": "try",
70-
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}$0"
85+
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}$0",
86+
"description" : "Code Snippet for a try and except blocks."
7187
},
7288
"try:except:else:finally": {
7389
"prefix": "tryef",
74-
"body": "try:\n\t${1:pass}\nexcept${2: ${3:Exception} as ${4:e}}:\n\t${5:raise}\nelse:\n\t${6:pass}\nfinally:\n\t${7:pass}$0"
90+
"body": "try:\n\t${1:pass}\nexcept${2: ${3:Exception} as ${4:e}}:\n\t${5:raise}\nelse:\n\t${6:pass}\nfinally:\n\t${7:pass}$0",
91+
"description" : "Code Snippet for a try/except/finally with else statement."
7592
},
7693
"try:except:else": {
7794
"prefix": "trye",
78-
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}$0"
95+
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}$0",
96+
"description" : "Code Snippet for a try/except with else statement."
7997
},
8098
"try:except:finally": {
8199
"prefix": "tryf",
82-
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}$0"
100+
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}$0",
101+
"description" : "Code Snippet for a try/except/finally."
83102
},
84103
"self": {
85104
"prefix": ".",
86-
"body": "self.$0"
105+
"body": "self.$0",
106+
"description" : "shortend snippet to reference the self property in an object."
87107
},
88108
"__magic__": {
89109
"prefix": "__",
90-
"body": "__${1:init}__$0"
110+
"body": "__${1:init}__$0",
111+
"description" : "Code snippet to create magic methods."
91112
},
92113
"if __name__ == \"__main__\"": {
93114
"prefix": "ifmain",
94-
"body": "if __name__ == \"__main__\":\n\t${1:main()}$0"
115+
"body": "if __name__ == \"__main__\":\n\t${1:main()}$0",
116+
"description" : "Create implicitly all the code at the top level using the __name__ special variable."
95117
}
96118
}

snippets/comprehension.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
11
{
22
"List comprehension": {
33
"prefix": "lc",
4-
"body": "[${1:value} for ${2:value} in ${3:iterable}]$0"
4+
"body": "[${1:value} for ${2:value} in ${3:iterable}]$0",
5+
"description" : "list comprehension for creating a list based on existing lists."
56
},
67
"List comprehension if else": {
78
"prefix": "lcie",
8-
"body": "[${1:value} if ${2:condition} else ${3:condition} for ${4:value} in ${5:iterable}]$0"
9+
"body": "[${1:value} if ${2:condition} else ${3:condition} for ${4:value} in ${5:iterable}]$0",
10+
"description" : "list comprehension for creating a list based on existing lists, with conditional if-else statement."
911
},
1012
"List comprehension if filter": {
1113
"prefix": "lci",
12-
"body": "[${1:value} for ${2:value} in ${3:iterable} if ${4:condition}$0]"
14+
"body": "[${1:value} for ${2:value} in ${3:iterable} if ${4:condition}$0]",
15+
"description" : "list comprehension for creating a list based on existing lists, with conditional if statement."
1316
},
1417
"Dictionary comprehension": {
1518
"prefix": "dc",
16-
"body": "{${1:key}: ${2:value} for ${3:key}, ${4:value} in ${5:iterable}}$0"
19+
"body": "{${1:key}: ${2:value} for ${3:key}, ${4:value} in ${5:iterable}}$0",
20+
"description" : "Handy and faster way to create dictories based on existing dictionaries."
1721
},
1822
"Dictionary comprehension if filter": {
1923
"prefix": "dci",
20-
"body": "{${1:key}: ${2:value} for ${3:key}, ${4:value} in ${5:iterable} if ${6:condition}}$0"
24+
"body": "{${1:key}: ${2:value} for ${3:key}, ${4:value} in ${5:iterable} if ${6:condition}}$0",
25+
"description" : "Handy and faster way to create dictories based on existing dictionaries, with conditional if statement."
2126
},
2227
"Set comprehension": {
2328
"prefix": "sc",
24-
"body": "{${1:value} for ${2:value} in ${3:iterable}}$0"
29+
"body": "{${1:value} for ${2:value} in ${3:iterable}}$0",
30+
"description" : "Create a set based on existing iterables."
2531
},
2632
"Set Comprehension if filter": {
2733
"prefix": "sci",
28-
"body": "{${1:value} for ${2:value} in ${3:iterable} if ${4:condition}}$0"
34+
"body": "{${1:value} for ${2:value} in ${3:iterable} if ${4:condition}}$0",
35+
"description" : "Create a set based on existing iterables, with condition if statement."
2936
},
3037
"Generator comprehension": {
3138
"prefix": "gc",
32-
"body": "(${1:key} for ${2:value} in ${3:iterable})$0"
39+
"body": "(${1:key} for ${2:value} in ${3:iterable})$0",
40+
"description" : "Create a generator based on existing iterables."
3341
},
3442
"Generator comprehension if filter": {
3543
"prefix": "gci",
36-
"body": "(${1:key} for ${2:value} in ${3:iterable} if ${4:condition})$0"
44+
"body": "(${1:key} for ${2:value} in ${3:iterable} if ${4:condition})$0",
45+
"description" : "Create a generator based on existing iterables, with condition if statement."
3746
}
3847
}

0 commit comments

Comments
 (0)