]> git.madduck.net Git - etc/vim.git/blob - tests/expression.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Remove the trailing comma if there is only one argument to a call
[etc/vim.git] / tests / expression.py
1 ...
2 'some_string'
3 b'\\xa3'
4 Name
5 None
6 True
7 False
8 1
9 1.0
10 1j
11 True or False
12 True or False or None
13 True and False
14 True and False and None
15 (Name1 and Name2) or Name3
16 Name1 and Name2 or Name3
17 Name1 or (Name2 and Name3)
18 Name1 or Name2 and Name3
19 (Name1 and Name2) or (Name3 and Name4)
20 Name1 and Name2 or Name3 and Name4
21 Name1 or (Name2 and Name3) or Name4
22 Name1 or Name2 and Name3 or Name4
23 v1 << 2
24 1 >> v2
25 1 % finished
26 1 + v2 - v3 * 4 ^ 5 ** v6 / 7 // 8
27 ((1 + v2) - (v3 * 4)) ^ (((5 ** v6) / 7) // 8)
28 not great
29 ~great
30 +value
31 -1
32 ~int and not v1 ^ 123 + v2 | True
33 (~int) and (not ((v1 ^ (123 + v2)) | True))
34 flags & ~ select.EPOLLIN and waiters.write_task is not None
35 lambda arg: None
36 lambda a=True: a
37 lambda a, b, c=True: a
38 lambda a, b, c=True, *, d=(1 << v2), e='str': a
39 lambda a, b, c=True, *vararg, d=(v1 << 2), e='str', **kwargs: a + b
40 1 if True else 2
41 str or None if True else str or bytes or None
42 (str or None) if True else (str or bytes or None)
43 str or None if (1 if True else 2) else str or bytes or None
44 (str or None) if (1 if True else 2) else (str or bytes or None)
45 {'2.7': dead, '3.7': (long_live or die_hard)}
46 {'2.7': dead, '3.7': (long_live or die_hard), **{'3.6': verygood}}
47 {**a, **b, **c}
48 {'2.7', '3.6', '3.7', '3.8', '3.9', ('4.0' if gilectomy else '3.10')}
49 ({'a': 'b'}, (True or False), (+value), 'string', b'bytes') or None
50 ()
51 (1,)
52 (1, 2)
53 (1, 2, 3)
54 []
55 [1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
56 {i for i in (1, 2, 3)}
57 {(i ** 2) for i in (1, 2, 3)}
58 {(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))}
59 {((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)}
60 [i for i in (1, 2, 3)]
61 [(i ** 2) for i in (1, 2, 3)]
62 [(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))]
63 [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)]
64 {i: 0 for i in (1, 2, 3)}
65 {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))}
66 {k: v for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension}
67 Python3 > Python2 > COBOL
68 Life is Life
69 call()
70 call(arg)
71 call(kwarg='hey')
72 call(arg, kwarg='hey')
73 call(arg, another, kwarg='hey', **kwargs)
74 call(this_is_a_very_long_variable_which_will_force_a_delimiter_split, arg, another, kwarg='hey', **kwargs)  # note: no trailing comma pre-3.6
75 call(*gidgets[:2])
76 lukasz.langa.pl
77 call.me(maybe)
78 1 .real
79 1.0 .real
80 ....__class__
81 list[str]
82 dict[str, int]
83 tuple[str, ...]
84 tuple[str, int, float, dict[str, int]]
85 slice[0]
86 slice[0:1]
87 slice[0:1:2]
88 slice[:]
89 slice[:-1]
90 slice[1:]
91 slice[::-1]
92 numpy[:, 0:1]
93 (str or None) if (sys.version_info[0] > (3,)) else (str or bytes or None)
94 {'2.7': dead, '3.7': long_live or die_hard}
95 {'2.7', '3.6', '3.7', '3.8', '3.9', '4.0' if gilectomy else '3.10'}
96 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
97 (SomeName)
98 SomeName
99 (Good, Bad, Ugly)
100 (i for i in (1, 2, 3))
101 ((i ** 2) for i in (1, 2, 3))
102 ((i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c')))
103 (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3))
104 (*starred)
105 a = (1,)
106 b = 1,
107 c = 1
108 d = (1,) + a + (2,)
109 e = (1,).count(1)
110 what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(vars_to_remove)
111 what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove)
112 result = session.query(models.Customer.id).filter(models.Customer.account_id == account_id, models.Customer.email == email_address).order_by(models.Customer.id.asc(),).all()
113
114 def gen():
115     yield from outside_of_generator
116     a = (yield)
117
118 async def f():
119     await some.complicated[0].call(with_args=(True or (1 is not 1)))
120
121
122 # output
123
124
125 ...
126 'some_string'
127 b'\\xa3'
128 Name
129 None
130 True
131 False
132 1
133 1.0
134 1j
135 True or False
136 True or False or None
137 True and False
138 True and False and None
139 (Name1 and Name2) or Name3
140 Name1 and Name2 or Name3
141 Name1 or (Name2 and Name3)
142 Name1 or Name2 and Name3
143 (Name1 and Name2) or (Name3 and Name4)
144 Name1 and Name2 or Name3 and Name4
145 Name1 or (Name2 and Name3) or Name4
146 Name1 or Name2 and Name3 or Name4
147 v1 << 2
148 1 >> v2
149 1 % finished
150 1 + v2 - v3 * 4 ^ 5 ** v6 / 7 // 8
151 ((1 + v2) - (v3 * 4)) ^ (((5 ** v6) / 7) // 8)
152 not great
153 ~great
154 +value
155 -1
156 ~int and not v1 ^ 123 + v2 | True
157 (~int) and (not ((v1 ^ (123 + v2)) | True))
158 flags & ~select.EPOLLIN and waiters.write_task is not None
159 lambda arg: None
160 lambda a=True: a
161 lambda a, b, c=True: a
162 lambda a, b, c=True, *, d=(1 << v2), e='str': a
163 lambda a, b, c=True, *vararg, d=(v1 << 2), e='str', **kwargs: a + b
164 1 if True else 2
165 str or None if True else str or bytes or None
166 (str or None) if True else (str or bytes or None)
167 str or None if (1 if True else 2) else str or bytes or None
168 (str or None) if (1 if True else 2) else (str or bytes or None)
169 {'2.7': dead, '3.7': (long_live or die_hard)}
170 {'2.7': dead, '3.7': (long_live or die_hard), **{'3.6': verygood}}
171 {**a, **b, **c}
172 {'2.7', '3.6', '3.7', '3.8', '3.9', ('4.0' if gilectomy else '3.10')}
173 ({'a': 'b'}, (True or False), (+value), 'string', b'bytes') or None
174 ()
175 (1,)
176 (1, 2)
177 (1, 2, 3)
178 []
179 [1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
180 {i for i in (1, 2, 3)}
181 {(i ** 2) for i in (1, 2, 3)}
182 {(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))}
183 {((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)}
184 [i for i in (1, 2, 3)]
185 [(i ** 2) for i in (1, 2, 3)]
186 [(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))]
187 [((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)]
188 {i: 0 for i in (1, 2, 3)}
189 {i: j for i, j in ((1, 'a'), (2, 'b'), (3, 'c'))}
190 {
191     k: v
192     for k, v in this_is_a_very_long_variable_which_will_cause_a_trailing_comma_which_breaks_the_comprehension
193 }
194 Python3 > Python2 > COBOL
195 Life is Life
196 call()
197 call(arg)
198 call(kwarg='hey')
199 call(arg, kwarg='hey')
200 call(arg, another, kwarg='hey', **kwargs)
201 call(
202     this_is_a_very_long_variable_which_will_force_a_delimiter_split,
203     arg,
204     another,
205     kwarg='hey',
206     **kwargs
207 )  # note: no trailing comma pre-3.6
208 call(*gidgets[:2])
209 lukasz.langa.pl
210 call.me(maybe)
211 1 .real
212 1.0 .real
213 ....__class__
214 list[str]
215 dict[str, int]
216 tuple[str, ...]
217 tuple[str, int, float, dict[str, int]]
218 slice[0]
219 slice[0:1]
220 slice[0:1:2]
221 slice[:]
222 slice[:-1]
223 slice[1:]
224 slice[::-1]
225 numpy[:, 0:1]
226 (str or None) if (sys.version_info[0] > (3,)) else (str or bytes or None)
227 {'2.7': dead, '3.7': long_live or die_hard}
228 {'2.7', '3.6', '3.7', '3.8', '3.9', '4.0' if gilectomy else '3.10'}
229 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
230 (SomeName)
231 SomeName
232 (Good, Bad, Ugly)
233 (i for i in (1, 2, 3))
234 ((i ** 2) for i in (1, 2, 3))
235 ((i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c')))
236 (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3))
237 (*starred)
238 a = (1,)
239 b = 1,
240 c = 1
241 d = (1,) + a + (2,)
242 e = (1,).count(1)
243 what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(
244     vars_to_remove
245 )
246 what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(
247     vars_to_remove
248 )
249 result = session.query(models.Customer.id).filter(
250     models.Customer.account_id == account_id, models.Customer.email == email_address
251 ).order_by(
252     models.Customer.id.asc()
253 ).all()
254
255
256 def gen():
257     yield from outside_of_generator
258
259     a = (yield)
260
261
262 async def f():
263     await some.complicated[0].call(with_args=(True or (1 is not 1)))