Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 25, 2025. It is now read-only.
/python-snippetsPublic archive

New "ima" and "fima" snippets#28

Open
Devcom439 wants to merge1 commit intocstrap:master
base:master
Choose a base branch
Loading
fromDevcom439:master
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
344 changes: 177 additions & 167 deletionssnippets/base.json
View file
Open in desktop
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You can see the added 2 snippets between line 43 and line 57

Original file line numberDiff line numberDiff line change
@@ -1,169 +1,179 @@
{
"#!/usr/bin/env python": {
"prefix": "env",
"body": "#!/usr/bin/env python\n$0",
"description" : "Adds shebang line for default python interpreter."
},
"#!/usr/bin/env python3": {
"prefix": "env3",
"body": "#!/usr/bin/env python3\n$0",
"description" : "Adds shebang line for default python 3 interpreter."
},
"# -*- coding=utf-8 -*-": {
"prefix": "enc",
"body": "# -*- coding=utf-8 -*-\n$0",
"description" : "set default python2.x encoding specification to utf-8 as it is mentioned in pep-0263."
},
"# coding=utf-8": {
"prefix": "enco",
"body": "# coding=utf-8\n$0",
"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."
},
"from future import ...": {
"prefix": "fenc",
"body": [
"# -*- coding: utf-8 -*-",
"from __future__ import absolute_import, division, print_function, unicode_literals"
],
"description" : "Import future statement definitions for python2.x scripts using utf-8 as encoding."
},
"from future import ... v1": {
"prefix": "fenco",
"body": [
"# coding: utf-8",
"from __future__ import absolute_import, division, print_function, unicode_literals"
],
"description" : "Import future statement definitions for python3.x scripts using utf-8 as encoding."
},
"import": {
"prefix": "im",
"body": "import ${1:package/module}$0",
"description" : "Import a package or module"
},
"from ... import ...": {
"prefix": "fim",
"body": "from ${1:package/module} import ${2:names}$0",
"description" : "Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table."
},
"New class": {
"prefix": "class",
"body": [
"class ${1:ClassName}(${2:object}):",
"\t\"\"\"${3:docstring for $1.}\"\"\"",
"\tdef __init__(self, ${4:arg}):",
"\t\t${5:super($1, self).__init__()}",
"\t${4/([^,=]+)(?:=[^,]+)?(,\\s*|)/\tself.$1 = $1${2:+\n\t}/g}",
"\n\t$0"
],
"description" : "Code snippet for a class definition."
},
"New dataclass": {
"prefix": "classd",
"body": [
"from dataclasses import dataclass\n\n",
"@dataclass",
"class ${1:ClassName}(${2:object}):",
"\t\"\"\"${3:Docstring for $1.}\"\"\"",
"\t${4:property}: ${type}",
"\t$0"
],
"description": "Code snippet for a dataclass definition."
},
"New method": {
"prefix": "defs",
"body": "def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0",
"description" : "Code snippet for a class method definition."
},
"New function": {
"prefix": "def",
"body": "def ${1:fname}(${2:arg}):\n\t${3:pass}$0",
"description" : "Code snippet for function definition."
},
"New async function": {
"prefix": "adef",
"body": "async def ${1:fname}(${2:arg}):\n\t${3:pass}$0",
"description" : "Code snippet for async function definition."
},
"New property": {
"prefix": "property",
"body": "@property\ndef ${1:foo}(self):\n \"\"\"${2:The $1 property.}\"\"\"\n ${3:return self._$1}\n@${4:$1}.setter\ndef ${5:$1}(self, value):\n ${6:self._$1} = value",
"description": "New property: get and set via decorator"
},
"New froperty": {
"prefix": "property",
"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",
"description" : ""
},
"New enum": {
"prefix": "enum",
"body": [
"from enum import Enum\n\n",
"class ${1:MyEnum}(Enum):",
"\t\"\"\"${2:Docstring for $1.}\"\"\"",
"\t${3:FIRST_ENUM} = \"some_value\"",
"\t${4:SECOND_ENUM} = \"some_other_value\"",
"\t$0"
],
"description": "Code snippet for enum definition."
},
"if": {
"prefix": "if",
"body": "if ${1:condition}:\n\t${2:pass}$0",
"description" : "Code snippet for the if statement."
},
"for": {
"prefix": "for",
"body": "for ${1:value} in ${2:iterable}:\n\t${3:pass}$0",
"description" : "Code snippet to create a for loop structure."
},
"while": {
"prefix": "while",
"body": "while ${1:condition}:\n\t${2:pass}$0",
"description" : "Code snippet to create a while loop structure."
},
"dowhile": {
"prefix": "dowhile",
"body": "do = True\nwhile do or ${2:condition}:\n\tdo = False\n\t${1:body}$0",
"description" : "Code snippet to create a do-while loop structure."
},
"try:except:": {
"prefix": "try",
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}$0",
"description" : "Code Snippet for a try and except blocks."
},
"try:except:else:finally": {
"prefix": "tryef",
"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",
"description" : "Code Snippet for a try/except/finally with else statement."
},
"try:except:else": {
"prefix": "trye",
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}$0",
"description" : "Code Snippet for a try/except with else statement."
},
"try:except:finally": {
"prefix": "tryf",
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}$0",
"description" : "Code Snippet for a try/except/finally."
},
"self": {
"prefix": "s",
"body": "self.$0",
"description" : "Shortend snippet to reference the self property in an object."
},
"__magic__": {
"prefix": "__",
"body": "__${1:init}__$0",
"description" : "Code snippet to create magic methods."
},
"if __name__ == \"__main__\"": {
"prefix": "ifmain",
"body": "if __name__ == \"__main__\":\n\t${1:main()}$0",
"description" : "Create implicitly all the code at the top level using the __name__ special variable."
},
"lambda": {
"prefix": "lam",
"body": "lambda ${1:args}: ${2:expr}",
"description": "Create template for lambda function"
}
"#!/usr/bin/env python": {
"prefix": "env",
"body": "#!/usr/bin/env python\n$0",
"description": "Adds shebang line for default python interpreter."
},
"#!/usr/bin/env python3": {
"prefix": "env3",
"body": "#!/usr/bin/env python3\n$0",
"description": "Adds shebang line for default python 3 interpreter."
},
"# -*- coding=utf-8 -*-": {
"prefix": "enc",
"body": "# -*- coding=utf-8 -*-\n$0",
"description": "set default python2.x encoding specification to utf-8 as it is mentioned in pep-0263."
},
"# coding=utf-8": {
"prefix": "enco",
"body": "# coding=utf-8\n$0",
"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."
},
"from future import ...": {
"prefix": "fenc",
"body": [
"# -*- coding: utf-8 -*-",
"from __future__ import absolute_import, division, print_function, unicode_literals"
],
"description": "Import future statement definitions for python2.x scripts using utf-8 as encoding."
},
"from future import ... v1": {
"prefix": "fenco",
"body": [
"# coding: utf-8",
"from __future__ import absolute_import, division, print_function, unicode_literals"
],
"description": "Import future statement definitions for python3.x scripts using utf-8 as encoding."
},
"import": {
"prefix": "im",
"body": "import ${1:package/module}$0",
"description": "Import a package or module"
},
"import as": {
"prefix": "ima",
"body": "import ${1:package/module} as ${2:name}$0",
"description": "Import a renamable package or module"
},
"from ... import ...": {
"prefix": "fim",
"body": "from ${1:package/module} import ${2:names}$0",
"description": "Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table."
},
"fima": {
"prefix": "fima",
"body": "from ${1:package/module} import ${2:names} as ${3:name}$0",
"description": "Import statement that allows individual objects from the module to be imported directly into the caller’s symbol table and be renamed."
},
"New class": {
"prefix": "class",
"body": [
"class ${1:ClassName}(${2:object}):",
"\t\"\"\"${3:docstring for $1.}\"\"\"",
"\tdef __init__(self, ${4:arg}):",
"\t\t${5:super($1, self).__init__()}",
"\t${4/([^,=]+)(?:=[^,]+)?(,\\s*|)/\tself.$1 = $1${2:+\n\t}/g}",
"\n\t$0"
],
"description": "Code snippet for a class definition."
},
"New dataclass": {
"prefix": "classd",
"body": [
"from dataclasses import dataclass\n\n",
"@dataclass",
"class ${1:ClassName}(${2:object}):",
"\t\"\"\"${3:Docstring for $1.}\"\"\"",
"\t${4:property}: ${type}",
"\t$0"
],
"description": "Code snippet for a dataclass definition."
},
"New method": {
"prefix": "defs",
"body": "def ${1:mname}(self, ${2:arg}):\n\t${3:pass}$0",
"description": "Code snippet for a class method definition."
},
"New function": {
"prefix": "def",
"body": "def ${1:fname}(${2:arg}):\n\t${3:pass}$0",
"description": "Code snippet for function definition."
},
"New async function": {
"prefix": "adef",
"body": "async def ${1:fname}(${2:arg}):\n\t${3:pass}$0",
"description": "Code snippet for async function definition."
},
"New property": {
"prefix": "property",
"body": "@property\ndef ${1:foo}(self):\n \"\"\"${2:The $1 property.}\"\"\"\n ${3:return self._$1}\n@${4:$1}.setter\ndef ${5:$1}(self, value):\n ${6:self._$1} = value",
"description": "New property: get and set via decorator"
},
"New froperty": {
"prefix": "property",
"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",
"description": ""
},
"New enum": {
"prefix": "enum",
"body": [
"from enum import Enum\n\n",
"class ${1:MyEnum}(Enum):",
"\t\"\"\"${2:Docstring for $1.}\"\"\"",
"\t${3:FIRST_ENUM} = \"some_value\"",
"\t${4:SECOND_ENUM} = \"some_other_value\"",
"\t$0"
],
"description": "Code snippet for enum definition."
},
"if": {
"prefix": "if",
"body": "if ${1:condition}:\n\t${2:pass}$0",
"description": "Code snippet for the if statement."
},
"for": {
"prefix": "for",
"body": "for ${1:value} in ${2:iterable}:\n\t${3:pass}$0",
"description": "Code snippet to create a for loop structure."
},
"while": {
"prefix": "while",
"body": "while ${1:condition}:\n\t${2:pass}$0",
"description": "Code snippet to create a while loop structure."
},
"dowhile": {
"prefix": "dowhile",
"body": "do = True\nwhile do or ${2:condition}:\n\tdo = False\n\t${1:body}$0",
"description": "Code snippet to create a do-while loop structure."
},
"try:except:": {
"prefix": "try",
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}$0",
"description": "Code Snippet for a try and except blocks."
},
"try:except:else:finally": {
"prefix": "tryef",
"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",
"description": "Code Snippet for a try/except/finally with else statement."
},
"try:except:else": {
"prefix": "trye",
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nelse:\n\t${5:pass}$0",
"description": "Code Snippet for a try/except with else statement."
},
"try:except:finally": {
"prefix": "tryf",
"body": "try:\n\t${1:pass}\nexcept ${2:Exception} as ${3:e}:\n\t${4:raise $3}\nfinally:\n\t${5:pass}$0",
"description": "Code Snippet for a try/except/finally."
},
"self": {
"prefix": "s",
"body": "self.$0",
"description": "Shortend snippet to reference the self property in an object."
},
"__magic__": {
"prefix": "__",
"body": "__${1:init}__$0",
"description": "Code snippet to create magic methods."
},
"if __name__ == \"__main__\"": {
"prefix": "ifmain",
"body": "if __name__ == \"__main__\":\n\t${1:main()}$0",
"description": "Create implicitly all the code at the top level using the __name__ special variable."
},
"lambda": {
"prefix": "lam",
"body": "lambda ${1:args}: ${2:expr}",
"description": "Create template for lambda function"
}
}

[8]ページ先頭

©2009-2025 Movatter.jp