File: extended_unpacking.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (49 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# mode: error

# invalid syntax (not handled by the parser)

def syntax1():
    a = b = c = d = e = f = g = h = i = 1 # prevent undefined names

    *a

    *1

    *"abc"

    *a*b

    [*a, *b]

    (a, b, *c, d, e, f, *g, h, i)
    [a, b, *c, d, e, f, *g, h, i]
    {a, b, *c, d, e, f, *g, h, i}


def syntax2():
    list_of_sequences = [[1,2], [3,4]]

    for *a,*b in list_of_sequences:
        pass


def types(l):
    cdef int a,b
    a, *b = (1,2,3,4)
    a, *b = l


_ERRORS = u"""
# syntax1()
 8: 4: starred expression is not allowed here
10: 4: starred expression is not allowed here
12: 4: starred expression is not allowed here
14: 4: starred expression is not allowed here

# syntax2()
26:11: more than 1 starred expression in assignment

# types()
32:15: Cannot coerce list to type 'int'
33:8: starred target must have Python object (list) type
"""