File: python2_strings.py

package info (click to toggle)
vim 2%3A9.1.2103-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 93,456 kB
  • sloc: ansic: 433,730; cpp: 6,399; makefile: 4,597; sh: 2,397; java: 2,312; xml: 2,099; python: 1,595; perl: 1,419; awk: 730; lisp: 501; cs: 458; objc: 369; sed: 8; csh: 6; haskell: 1
file content (82 lines) | stat: -rw-r--r-- 3,238 bytes parent folder | download
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# String literals
# https://docs.python.org/2/reference/lexical_analysis.html#string-literals

# Strings: Source encoding, no Unicode escape sequences
test = 'String with escapes \' and \" and \t'
test = "String with escapes \040 and \xFF"
test = 'String with literal \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK}'
test = "String with escaped \\ backslash and ignored \
newline"
test = '''String with quotes ' and "
and escapes \t and \040 and \xFF
and literal \u00A1 and \U00010605'''
test = """String with quotes ' and "
and escapes \t and \040 and \xFF
and literal \u00A1 and \U00010605"""

# Raw strings
test = r'Raw string with literal \' and \" and \t'
test = R"Raw string with literal \040 and \xFF"
test = r'Raw string with literal \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK}'
test = R"Raw string with literal \\ backslashes and literal \
newline"
test = r'''Raw string with quotes ' and "
and literal \t and \040 and \xFF
and literal \u00A1 and \U00010605'''
test = R"""Raw string with quotes ' and "
and literal \t and \040 and \xFF
and literal \u00A1 and \U00010605"""

# B-strings: Prefix is allowed but ignored (https://peps.python.org/pep-3112)
test = b'String with escapes \' and \" and \t'
test = B"String with escapes \040 and \xFF"
test = b'String with literal \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK}'
test = B"String with escaped \\ backslash and ignored \
newline"
test = b'''String with quotes ' and "
and escapes \t and \040 and \xFF
and literal \u00A1 and \U00010605'''
test = B"""String with quotes ' and "
and escapes \t and \040 and \xFF
and literal \u00A1 and \U00010605"""

# Raw b-strings
test = br'Raw string with literal \' and \" and \t'
test = bR"Raw string with literal \040 and \xFF"
test = Br'Raw string with literal \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK}'
test = BR"Raw string with literal \\ backslashes and literal \
newline"
test = br'''Raw string with quotes ' and "
and literal \t and \040 and \xFF
and literal \u00A1 and \U00010605'''
test = BR"""Raw string with quotes ' and "
and literal \t and \040 and \xFF
and literal \u00A1 and \U00010605"""

# Unicode strings
test = u'String with escapes \' and \" and \t'
test = U"String with escapes \040 and \xFF"
test = u'String with escapes \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK}'
test = U"String with escaped \\ backslash and ignored \
newline"
test = u'''String with quotes ' and "
and escapes \t and \040 and \xFF
and escapes \u00A1 and \U00010605'''
test = U"""String with quotes ' and "
and escapes \t and \040 and \xFF
and escapes \u00A1 and \U00010605"""

# Raw Unicode strings: Only Unicode escape sequences
test = ur'Raw Unicode string with literal \' and \" and \t'
test = uR"Raw Unicode string with literal \040 and \xFF"
test = Ur'Raw Unicode string with escapes \u00A1 and \U00010605 and \N{INVERTED EXCLAMATION MARK}'
test = UR"Raw Unicode string with literal \\ backslashes and literal \
newline"
test = ur'''Raw Unicode string with quotes ' and "
and literal \t and \040 and \xFF
and escapes \u00A1 and \U00010605'''
test = UR"""Raw Unicode string with quotes ' and "
and literal \t and \040 and \xFF
and escapes \u00A1 and \U00010605"""

# vim: syntax=python2