cython

Форк
0
/
posonly.py 
559 строк · 18.3 Кб
1
# cython: always_allow_keywords=True
2
# mode: run
3
# tag: posonly, pure3.8
4

5
import cython
6
import pickle
7

8
def test_optional_posonly_args1(a, b=10, /, c=100):
9
    """
10
    >>> test_optional_posonly_args1(1, 2, 3)
11
    6
12
    >>> test_optional_posonly_args1(1, 2, c=3)
13
    6
14
    >>> test_optional_posonly_args1(1, b=2, c=3)  # doctest: +ELLIPSIS
15
    Traceback (most recent call last):
16
    TypeError: test_optional_posonly_args1() got ... keyword argument... 'b'
17
    >>> test_optional_posonly_args1(1, 2)
18
    103
19
    >>> test_optional_posonly_args1(1, b=2)  # doctest: +ELLIPSIS
20
    Traceback (most recent call last):
21
    TypeError: test_optional_posonly_args1() got ... keyword argument... 'b'
22
    """
23
    return a + b + c
24

25
def test_optional_posonly_args2(a=1, b=10, /, c=100):
26
    """
27
    >>> test_optional_posonly_args2(1, 2, 3)
28
    6
29
    >>> test_optional_posonly_args2(1, 2, c=3)
30
    6
31
    >>> test_optional_posonly_args2(1, b=2, c=3)  # doctest: +ELLIPSIS
32
    Traceback (most recent call last):
33
    TypeError: test_optional_posonly_args2() got ... keyword argument... 'b'
34
    >>> test_optional_posonly_args2(1, 2)
35
    103
36
    >>> test_optional_posonly_args2(1, b=2)  # doctest: +ELLIPSIS
37
    Traceback (most recent call last):
38
    TypeError: test_optional_posonly_args2() got ... keyword argument... 'b'
39
    >>> test_optional_posonly_args2(1, c=2)
40
    13
41
    """
42
    return a + b + c
43

44
# TODO: this causes a line that is too long for old versions of Clang
45
#def many_args(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,
46
#              a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,
47
#              a41,a42,a43,a44,a45,a46,a47,a48,a49,a50,a51,a52,a53,a54,a55,a56,a57,a58,a59,
48
#              a60,a61,a62,a63,a64,a65,a66,a67,a68,a69,a70,a71,a72,a73,a74,a75,a76,a77,a78,
49
#              a79,a80,a81,a82,a83,a84,a85,a86,a87,a88,a89,a90,a91,a92,a93,a94,a95,a96,a97,
50
#              a98,a99,a100,a101,a102,a103,a104,a105,a106,a107,a108,a109,a110,a111,a112,
51
#              a113,a114,a115,a116,a117,a118,a119,a120,a121,a122,a123,a124,a125,a126,a127,
52
#              a128,a129,a130,a131,a132,a133,a134,a135,a136,a137,a138,a139,a140,a141,a142,
53
#              a143,a144,a145,a146,a147,a148,a149,a150,a151,a152,a153,a154,a155,a156,a157,
54
#              a158,a159,a160,a161,a162,a163,a164,a165,a166,a167,a168,a169,a170,a171,a172,
55
#              a173,a174,a175,a176,a177,a178,a179,a180,a181,a182,a183,a184,a185,a186,a187,
56
#              a188,a189,a190,a191,a192,a193,a194,a195,a196,a197,a198,a199,a200,a201,a202,
57
#              a203,a204,a205,a206,a207,a208,a209,a210,a211,a212,a213,a214,a215,a216,a217,
58
#              a218,a219,a220,a221,a222,a223,a224,a225,a226,a227,a228,a229,a230,a231,a232,
59
#              a233,a234,a235,a236,a237,a238,a239,a240,a241,a242,a243,a244,a245,a246,a247,
60
#              a248,a249,a250,a251,a252,a253,a254,a255,a256,a257,a258,a259,a260,a261,a262,
61
#              a263,a264,a265,a266,a267,a268,a269,a270,a271,a272,a273,a274,a275,a276,a277,
62
#              a278,a279,a280,a281,a282,a283,a284,a285,a286,a287,a288,a289,a290,a291,a292,
63
#              a293,a294,a295,a296,a297,a298,a299,/,b,c=42,*,d):
64
#    """
65
#    >>> many_args(*range(299),b=1,c=2,d=3)
66
#    (298, 1, 2, 3)
67
#    >>> many_args(*range(299),b=1,d=3)
68
#    (298, 1, 42, 3)
69
#    >>> many_args(*range(300),d=3)
70
#    (298, 299, 42, 3)
71
#    """
72
#    return (a299, b, c, d)
73

74
#TODO: update this test for Python 3.8 final
75
@cython.binding(True)
76
def func_introspection1(a, b, c, /, d, e=1, *, f, g=2):
77
    """
78
    >>> assert func_introspection2.__code__.co_argcount == 5, func_introspection2.__code__.co_argcount
79
    >>> func_introspection1.__defaults__
80
    (1,)
81
    """
82

83
@cython.binding(True)
84
def func_introspection2(a, b, c=1, /, d=2, e=3, *, f, g=4):
85
    """
86
    >>> assert func_introspection2.__code__.co_argcount == 5, func_introspection2.__code__.co_argcount
87
    >>> func_introspection2.__defaults__
88
    (1, 2, 3)
89
    """
90

91
def test_pos_only_call_via_unpacking(a, b, /):
92
    """
93
    >>> test_pos_only_call_via_unpacking(*[1,2])
94
    3
95
    """
96
    return a + b
97

98
def test_use_positional_as_keyword1(a, /):
99
    """
100
    >>> test_use_positional_as_keyword1(1)
101
    >>> test_use_positional_as_keyword1(a=1)  # doctest: +ELLIPSIS
102
    Traceback (most recent call last):
103
    TypeError: test_use_positional_as_keyword1() ... keyword argument...
104
    """
105

106
def test_use_positional_as_keyword2(a, /, b):
107
    """
108
    >>> test_use_positional_as_keyword2(1, 2)
109
    >>> test_use_positional_as_keyword2(1, b=2)
110
    >>> test_use_positional_as_keyword2(a=1, b=2)  # doctest: +ELLIPSIS
111
    Traceback (most recent call last):
112
    TypeError: test_use_positional_as_keyword2() ... positional...argument...
113
    """
114

115
def test_use_positional_as_keyword3(a, b, /):
116
    """
117
    >>> test_use_positional_as_keyword3(1, 2)
118
    >>> test_use_positional_as_keyword3(a=1, b=2) # doctest:+ELLIPSIS
119
    Traceback (most recent call last):
120
    TypeError: test_use_positional_as_keyword3() got ... keyword argument...
121
    """
122

123
def test_positional_only_and_arg_invalid_calls(a, b, /, c):
124
    """
125
    >>> test_positional_only_and_arg_invalid_calls(1, 2, 3)
126
    >>> test_positional_only_and_arg_invalid_calls(1, 2, c=3)
127
    >>> test_positional_only_and_arg_invalid_calls(1, 2)  # doctest: +ELLIPSIS
128
    Traceback (most recent call last):
129
    TypeError: test_positional_only_and_arg_invalid_calls() ... positional argument...
130
    >>> test_positional_only_and_arg_invalid_calls(1)  # doctest: +ELLIPSIS
131
    Traceback (most recent call last):
132
    TypeError: test_positional_only_and_arg_invalid_calls() ... positional arguments...
133
    >>> test_positional_only_and_arg_invalid_calls(1,2,3,4)  # doctest: +ELLIPSIS
134
    Traceback (most recent call last):
135
    TypeError: test_positional_only_and_arg_invalid_calls() takes ... positional arguments ...4 ...given...
136
    """
137

138
def test_positional_only_and_optional_arg_invalid_calls(a, b, /, c=3):
139
    """
140
    >>> test_positional_only_and_optional_arg_invalid_calls(1, 2)
141
    >>> test_positional_only_and_optional_arg_invalid_calls(1)  # doctest: +ELLIPSIS
142
    Traceback (most recent call last):
143
    TypeError: test_positional_only_and_optional_arg_invalid_calls() ... positional argument...
144
    >>> test_positional_only_and_optional_arg_invalid_calls()  # doctest: +ELLIPSIS
145
    Traceback (most recent call last):
146
    TypeError: test_positional_only_and_optional_arg_invalid_calls() ... positional arguments...
147
    >>> test_positional_only_and_optional_arg_invalid_calls(1, 2, 3, 4)  # doctest: +ELLIPSIS
148
    Traceback (most recent call last):
149
    TypeError: test_positional_only_and_optional_arg_invalid_calls() takes ... positional arguments ...4 ...given...
150
    """
151

152
def test_positional_only_and_kwonlyargs_invalid_calls(a, b, /, c, *, d, e):
153
    """
154
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1, 2, 3, d=1, e=2)
155
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1, 2, 3, e=2)  # doctest: +ELLIPSIS
156
    Traceback (most recent call last):
157
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() ... keyword-only argument...d...
158
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1, 2, 3)  # doctest: +ELLIPSIS
159
    Traceback (most recent call last):
160
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() ... keyword-only argument...d...
161
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1, 2)  # doctest: +ELLIPSIS
162
    Traceback (most recent call last):
163
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() ... positional argument...
164
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1)  # doctest: +ELLIPSIS
165
    Traceback (most recent call last):
166
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() ... positional arguments...
167
    >>> test_positional_only_and_kwonlyargs_invalid_calls()  # doctest: +ELLIPSIS
168
    Traceback (most recent call last):
169
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() ... positional arguments...
170
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1, 2, 3, 4, 5, 6, d=7, e=8)  # doctest: +ELLIPSIS
171
    Traceback (most recent call last):
172
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() takes ... positional arguments ...
173
    >>> test_positional_only_and_kwonlyargs_invalid_calls(1, 2, 3, d=1, e=4, f=56)  # doctest: +ELLIPSIS
174
    Traceback (most recent call last):
175
    TypeError: test_positional_only_and_kwonlyargs_invalid_calls() got an unexpected keyword argument 'f'
176
    """
177

178
def test_positional_only_invalid_calls(a, b, /):
179
    """
180
    >>> test_positional_only_invalid_calls(1, 2)
181
    >>> test_positional_only_invalid_calls(1)  # doctest: +ELLIPSIS
182
    Traceback (most recent call last):
183
    TypeError: test_positional_only_invalid_calls() ... positional argument...
184
    >>> test_positional_only_invalid_calls()  # doctest: +ELLIPSIS
185
    Traceback (most recent call last):
186
    TypeError: test_positional_only_invalid_calls() ... positional arguments...
187
    >>> test_positional_only_invalid_calls(1, 2, 3)  # doctest: +ELLIPSIS
188
    Traceback (most recent call last):
189
    TypeError: test_positional_only_invalid_calls() takes ... positional arguments ...3 ...given...
190
    """
191

192
def test_positional_only_with_optional_invalid_calls(a, b=2, /):
193
    """
194
    >>> test_positional_only_with_optional_invalid_calls(1)
195
    >>> test_positional_only_with_optional_invalid_calls()  # doctest: +ELLIPSIS
196
    Traceback (most recent call last):
197
    TypeError: test_positional_only_with_optional_invalid_calls() ... positional argument...
198
    >>> test_positional_only_with_optional_invalid_calls(1, 2, 3)  # doctest: +ELLIPSIS
199
    Traceback (most recent call last):
200
    TypeError: test_positional_only_with_optional_invalid_calls() takes ... positional arguments ...3 ...given...
201
    """
202

203
def test_no_standard_args_usage(a, b, /, *, c):
204
    """
205
    >>> test_no_standard_args_usage(1, 2, c=3)
206
    >>> test_no_standard_args_usage(1, b=2, c=3)  # doctest: +ELLIPSIS
207
    Traceback (most recent call last):
208
    TypeError: test_no_standard_args_usage() ... positional... argument...
209
    """
210

211
#def test_change_default_pos_only():
212
# TODO: probably remove this, since  __defaults__ is not writable in Cython?
213
#    """
214
#    >>> test_change_default_pos_only()
215
#    True
216
#    True
217
#    """
218
#    def f(a, b=2, /, c=3):
219
#        return a + b + c
220
#
221
#    print((2,3) == f.__defaults__)
222
#    f.__defaults__ = (1, 2, 3)
223
#    print(f(1, 2, 3) == 6)
224

225
def test_lambdas():
226
    """
227
    >>> test_lambdas()
228
    3
229
    3
230
    3
231
    3
232
    3
233
    """
234
    x = lambda a, /, b: a + b
235
    print(x(1,2))
236
    print(x(1,b=2))
237

238
    x = lambda a, /, b=2: a + b
239
    print(x(1))
240

241
    x = lambda a, b, /: a + b
242
    print(x(1, 2))
243

244
    x = lambda a, b, /, : a + b
245
    print(x(1, 2))
246

247
class TestPosonlyMethods(object):
248
    """
249
    >>> TestPosonlyMethods().f(1,2)
250
    (1, 2)
251
    >>> TestPosonlyMethods.f(TestPosonlyMethods(), 1, 2)
252
    (1, 2)
253
    >>> try:
254
    ...     TestPosonlyMethods.f(1,2)
255
    ... except TypeError:
256
    ...    print("Got type error")
257
    Got type error
258
    >>> TestPosonlyMethods().f(1, b=2)  # doctest: +ELLIPSIS
259
    Traceback (most recent call last):
260
    TypeError: ...f() got ... keyword argument... 'b'
261
    """
262
    def f(self, a, b, /):
263
        return a, b
264

265
class TestMangling(object):
266
    """
267
    >>> TestMangling().f()
268
    42
269
    >>> TestMangling().f2()
270
    42
271

272
    #>>> TestMangling().f3()
273
    #(42, 43)
274
    #>>> TestMangling().f4()
275
    #(42, 43, 44)
276

277
    >>> TestMangling().f2(1)
278
    1
279

280
    #>>> TestMangling().f3(1, _TestMangling__b=2)
281
    #(1, 2)
282
    #>>> TestMangling().f4(1, _TestMangling__b=2, _TestMangling__c=3)
283
    #(1, 2, 3)
284
    """
285
    def f(self, *, __a=42):
286
        return __a
287

288
    def f2(self, __a=42, /):
289
        return __a
290

291
# FIXME: https://github.com/cython/cython/issues/1382
292
#    def f3(self, __a=42, /, __b=43):
293
#        return (__a, __b)
294

295
#    def f4(self, __a=42, /, __b=43, *, __c=44):
296
#        return (__a, __b, __c)
297

298
def test_module_function(a, b, /):
299
    """
300
    >>> test_module_function(1, 2)
301
    >>> test_module_function()  # doctest: +ELLIPSIS
302
    Traceback (most recent call last):
303
    TypeError: test_module_function() ... positional arguments...
304
    """
305

306
def test_closures1(x,y):
307
    """
308
    >>> test_closures1(1,2)(3,4)
309
    10
310
    >>> test_closures1(1,2)(3)  # doctest: +ELLIPSIS
311
    Traceback (most recent call last):
312
    TypeError: ...g() ... positional argument...
313
    >>> test_closures1(1,2)(3,4,5)  # doctest: +ELLIPSIS
314
    Traceback (most recent call last):
315
    TypeError: ...g() ... positional argument...
316
    """
317
    def g(x2, /, y2):
318
        return x + y + x2 + y2
319
    return g
320

321
def test_closures2(x, /, y):
322
    """
323
    >>> test_closures2(1,2)(3,4)
324
    10
325
    """
326
    def g(x2,y2):
327
        return x + y + x2 + y2
328
    return g
329

330

331
def test_closures3(x, /, y):
332
    """
333
    >>> test_closures3(1,2)(3,4)
334
    10
335
    >>> test_closures3(1,2)(3)  # doctest: +ELLIPSIS
336
    Traceback (most recent call last):
337
    TypeError: ...g() ... positional argument...
338
    >>> test_closures3(1,2)(3,4,5)  # doctest: +ELLIPSIS
339
    Traceback (most recent call last):
340
    TypeError: ...g() ... positional argument...
341
    """
342
    def g(x2, /, y2):
343
        return x + y + x2 + y2
344
    return g
345

346

347
def test_same_keyword_as_positional_with_kwargs(something, /, **kwargs):
348
    """
349
    >>> test_same_keyword_as_positional_with_kwargs(42, something=42)
350
    (42, {'something': 42})
351
    >>> test_same_keyword_as_positional_with_kwargs(something=42)  # doctest: +ELLIPSIS
352
    Traceback (most recent call last):
353
    TypeError: test_same_keyword_as_positional_with_kwargs() ... positional argument...
354
    >>> test_same_keyword_as_positional_with_kwargs(42)
355
    (42, {})
356
    """
357
    return (something, kwargs)
358

359
def test_serialization1(a, b, /):
360
    """
361
    >>> pickled_posonly = pickle.dumps(test_serialization1)
362
    >>> unpickled_posonly = pickle.loads(pickled_posonly)
363
    >>> unpickled_posonly(1, 2)
364
    (1, 2)
365
    >>> unpickled_posonly(a=1, b=2)  # doctest: +ELLIPSIS
366
    Traceback (most recent call last):
367
    TypeError: test_serialization1() got ... keyword argument...
368
    """
369
    return (a, b)
370

371
def test_serialization2(a, /, b):
372
    """
373
    >>> pickled_optional = pickle.dumps(test_serialization2)
374
    >>> unpickled_optional = pickle.loads(pickled_optional)
375
    >>> unpickled_optional(1, 2)
376
    (1, 2)
377
    >>> unpickled_optional(a=1, b=2)  # doctest: +ELLIPSIS
378
    Traceback (most recent call last):
379
    TypeError: test_serialization2() ... positional... argument...
380
    """
381
    return (a, b)
382

383
def test_serialization3(a=1, /, b=2):
384
    """
385
    >>> pickled_defaults = pickle.dumps(test_serialization3)
386
    >>> unpickled_defaults = pickle.loads(pickled_defaults)
387
    >>> unpickled_defaults(1, 2)
388
    (1, 2)
389
    >>> unpickled_defaults(a=1, b=2)  # doctest: +ELLIPSIS
390
    Traceback (most recent call last):
391
    TypeError: test_serialization3() got ... keyword argument... 'a'
392
    """
393
    return (a, b)
394

395

396
async def test_async(a=1, /, b=2):
397
    """
398
    >>> test_async(a=1, b=2)  # doctest: +ELLIPSIS
399
    Traceback (most recent call last):
400
    TypeError: test_async() got ... keyword argument... 'a'
401
    """
402
    return a, b
403

404

405
def test_async_call(*args, **kwargs):
406
    """
407
    >>> test_async_call(1, 2)
408
    >>> test_async_call(1, b=2)
409
    >>> test_async_call(1)
410
    >>> test_async_call()
411
    """
412
    try:
413
        coro = test_async(*args, **kwargs)
414
        coro.send(None)
415
    except StopIteration as e:
416
        result = e.value
417
    assert result == (1, 2), result
418

419

420
def test_generator(a=1, /, b=2):
421
    """
422
    >>> test_generator(a=1, b=2)  # doctest: +ELLIPSIS
423
    Traceback (most recent call last):
424
    TypeError: test_generator() got ... keyword argument... 'a'
425
    >>> gen = test_generator(1, 2)
426
    >>> next(gen)
427
    (1, 2)
428
    >>> gen = test_generator(1, b=2)
429
    >>> next(gen)
430
    (1, 2)
431
    >>> gen = test_generator(1)
432
    >>> next(gen)
433
    (1, 2)
434
    >>> gen = test_generator()
435
    >>> next(gen)
436
    (1, 2)
437
    """
438
    yield a, b
439

440
def f_call_1_0_0(a,/):
441
    """
442
    >>> f_call_1_0_0(1)
443
    (1,)
444
    """
445
    return (a,)
446

447
def f_call_1_1_0(a, /, b):
448
    """
449
    >>> f_call_1_1_0(1,2)
450
    (1, 2)
451
    """
452
    return (a,b)
453

454
def f_call_1_1_1(a, /, b, *, c):
455
    """
456
    >>> f_call_1_1_1(1,2,c=3)
457
    (1, 2, 3)
458
    """
459
    return (a,b,c)
460

461
def f_call_1_1_1_star(a, /, b, *args, c):
462
    """
463
    >>> f_call_1_1_1_star(1,2,c=3)
464
    (1, 2, (), 3)
465
    >>> f_call_1_1_1_star(1,2,3,4,5,6,7,8,c=9)
466
    (1, 2, (3, 4, 5, 6, 7, 8), 9)
467
    """
468
    return (a,b,args,c)
469

470
def f_call_1_1_1_kwds(a, /, b, *, c, **kwds):
471
    """
472
    >>> f_call_1_1_1_kwds(1,2,c=3)
473
    (1, 2, 3, {})
474
    >>> f_call_1_1_1_kwds(1,2,c=3,d=4,e=5) == (1, 2, 3, {'d': 4, 'e': 5})
475
    True
476
    """
477
    return (a,b,c,kwds)
478

479
def f_call_1_1_1_star_kwds(a, /, b, *args, c, **kwds):
480
    """
481
    >>> f_call_1_1_1_star_kwds(1,2,c=3,d=4,e=5) == (1, 2, (), 3, {'d': 4, 'e': 5})
482
    True
483
    >>> f_call_1_1_1_star_kwds(1,2,3,4,c=5,d=6,e=7) == (1, 2, (3, 4), 5, {'d': 6, 'e': 7})
484
    True
485
    """
486
    return (a,b,args,c,kwds)
487

488
def f_call_one_optional_kwd(a, /, *, b=2):
489
    """
490
    >>> f_call_one_optional_kwd(1)
491
    (1, 2)
492
    >>> f_call_one_optional_kwd(1, b=3)
493
    (1, 3)
494
    """
495
    return (a,b)
496

497
def f_call_posonly_stararg(a, /, *args):
498
    """
499
    >>> f_call_posonly_stararg(1)
500
    (1, ())
501
    >>> f_call_posonly_stararg(1, 2, 3, 4)
502
    (1, (2, 3, 4))
503
    """
504
    return (a,args)
505

506
def f_call_posonly_kwarg(a, /, **kw):
507
    """
508
    >>> f_call_posonly_kwarg(1)
509
    (1, {})
510
    >>> all_args = f_call_posonly_kwarg(1, b=2, c=3, d=4)
511
    >>> all_args == (1, {'b': 2, 'c': 3, 'd': 4}) or all_args
512
    True
513
    """
514
    return (a,kw)
515

516
def f_call_posonly_stararg_kwarg(a, /, *args, **kw):
517
    """
518
    >>> f_call_posonly_stararg_kwarg(1)
519
    (1, (), {})
520
    >>> f_call_posonly_stararg_kwarg(1, 2)
521
    (1, (2,), {})
522
    >>> all_args = f_call_posonly_stararg_kwarg(1, b=3, c=4)
523
    >>> all_args == (1, (), {'b': 3, 'c': 4}) or all_args
524
    True
525
    >>> all_args = f_call_posonly_stararg_kwarg(1, 2, b=3, c=4)
526
    >>> all_args == (1, (2,), {'b': 3, 'c': 4}) or all_args
527
    True
528
    """
529
    return (a,args,kw)
530

531
def test_empty_kwargs(a, b, /):
532
    """
533
    >>> test_empty_kwargs(1, 2)
534
    (1, 2)
535
    >>> test_empty_kwargs(1, 2, **{})
536
    (1, 2)
537
    >>> test_empty_kwargs(1, 2, **{'c': 3})
538
    Traceback (most recent call last):
539
    TypeError: test_empty_kwargs() got an unexpected keyword argument 'c'
540
    """
541
    return (a,b)
542

543

544
@cython.cclass
545
class TestExtensionClass:
546
    """
547
    >>> t = TestExtensionClass()
548
    >>> t.f(1,2)
549
    (1, 2, 3)
550
    >>> t.f(1,2,4)
551
    (1, 2, 4)
552
    >>> t.f(1, 2, c=4)
553
    (1, 2, 4)
554
    >>> t.f(1, 2, 5, c=6)  # doctest: +ELLIPSIS
555
    Traceback (most recent call last):
556
    TypeError: ...f() got multiple values for ...argument 'c'
557
    """
558
    def f(self, a, b, /, c=3):
559
        return (a,b,c)
560

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.