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

Commit9a91957

Browse files
authored
feat(python): change order of navigation in comprehension snippets (rafamadriz#485)
This change is motivated by getting better completions when using alanguage server. When starting from the `iterable` part of the snippet,the language server can infer the type of the values contained in theiterable, so that when we get to the part of writing the `value` it canoffer autocompletion and suggestions for fields and methods of `value`.
1 parent00ba9dd commit9a91957

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎snippets/python/comprehension.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
{
22
"List comprehension": {
33
"prefix":"lc",
4-
"body":"[${1:value} for ${2:value} in ${3:iterable}]$0",
4+
"body":"[${3:value} for ${2:value} in ${1:iterable}]$0",
55
"description":"List comprehension for creating a list based on existing lists."
66
},
77
"List comprehension if else": {
88
"prefix":"lcie",
9-
"body":"[${1:value} if ${2:condition} else ${3:condition} for ${4:value} in ${5:iterable}]$0",
9+
"body":"[${3:value} if ${4:condition} else ${5:condition} for ${2:value} in ${1:iterable}]$0",
1010
"description":"List comprehension for creating a list based on existing lists, with conditional if-else statement."
1111
},
1212
"List comprehension if filter": {
1313
"prefix":"lci",
14-
"body":"[${1:value} for ${2:value} in ${3:iterable} if ${4:condition}$0]",
14+
"body":"[${3:value} for ${2:value} in ${1:iterable} if ${4:condition}$0]",
1515
"description":"List comprehension for creating a list based on existing lists, with conditional if statement."
1616
},
1717
"Dictionary comprehension": {
1818
"prefix":"dc",
19-
"body":"{${1:key}: ${2:value} for ${3:key}, ${4:value} in ${5:iterable}}$0",
19+
"body":"{${4:key}: ${5:value} for ${2:key}, ${3:value} in ${1:iterable}}$0",
2020
"description":"Handy and faster way to create dictionaries based on existing dictionaries."
2121
},
2222
"Dictionary comprehension if filter": {
2323
"prefix":"dci",
24-
"body":"{${1:key}: ${2:value} for ${3:key}, ${4:value} in ${5:iterable} if ${6:condition}}$0",
24+
"body":"{${4:key}: ${5:value} for ${2:key}, ${3:value} in ${1:iterable} if ${6:condition}}$0",
2525
"description":"Handy and faster way to create dictionaries based on existing dictionaries, with conditional if statement."
2626
},
2727
"Set comprehension": {
2828
"prefix":"sc",
29-
"body":"{${1:value} for ${2:value} in ${3:iterable}}$0",
29+
"body":"{${3:value} for ${2:value} in ${1:iterable}}$0",
3030
"description":"Create a set based on existing iterables."
3131
},
3232
"Set Comprehension if filter": {
3333
"prefix":"sci",
34-
"body":"{${1:value} for ${2:value} in ${3:iterable} if ${4:condition}}$0",
34+
"body":"{${3:value} for ${2:value} in ${1:iterable} if ${4:condition}}$0",
3535
"description":"Create a set based on existing iterables, with condition if statement."
3636
},
3737
"Generator comprehension": {
3838
"prefix":"gc",
39-
"body":"(${1:key} for ${2:value} in ${3:iterable})$0",
39+
"body":"(${3:key} for ${2:value} in ${1:iterable})$0",
4040
"description":"Create a generator based on existing iterables."
4141
},
4242
"Generator comprehension if filter": {
4343
"prefix":"gci",
44-
"body":"(${1:key} for ${2:value} in ${3:iterable} if ${4:condition})$0",
44+
"body":"(${3:key} for ${2:value} in ${1:iterable} if ${4:condition})$0",
4545
"description":"Create a generator based on existing iterables, with condition if statement."
4646
}
4747
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp