File: literalslice.pyx

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: 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 (54 lines) | stat: -rw-r--r-- 882 bytes parent folder | download | duplicates (12)
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
__doc__ = u"""
  >>> test_str(1)
  'b'

  >>> test_unicode_ascii(2)
  u'c'
  >>> test_unicode(2) == u'\u00e4'
  True

  >>> test_int_list(2)
  3
  >>> test_str_list(1)
  'bcd'

  >>> test_int_tuple(2)
  3
  >>> test_str_tuple(0)
  'a'
  >>> test_mix_tuple(1)
  'abc'
  >>> test_mix_tuple(0)
  1
"""

import sys
IS_PY3 = sys.version_info[0] >= 3
if IS_PY3:
    __doc__ = __doc__.replace(u" u'", u" '")
else:
    __doc__ = __doc__.replace(u" b'", u" '")

def test_str(n):
    return "abcd"[n]

def test_unicode_ascii(n):
    return u"abcd"[n]

def test_unicode(n):
    return u"\u00fc\u00f6\u00e4"[n]

def test_int_list(n):
    return [1,2,3,4][n]

def test_str_list(n):
    return ["a","bcd","efg","xyz"][n]

def test_int_tuple(n):
    return (1,2,3,4)[n]

def test_str_tuple(n):
    return ("a","bcd","efg","xyz")[n]

def test_mix_tuple(n):
    return (1, "abc", u"\u00fc", 1.1)[n]