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
|
__doc__ = u"""
>>> str('test')
'test'
>>> z
'test'
"""
cimport cython
s = str
z = str('test')
def c(string):
"""
>>> c('testing')
'testing'
"""
return str(string)
class subs(str):
"""
>>> subs('testing a subtype')
'testing a subtype'
# >>> csub('testing a subtype')
# 'testing a subtype'
# >>> csubs('testing a subtype')
# 'testing a subtype'
"""
pass
def sub(string):
"""
>>> sub('testing a subtype')
'testing a subtype'
"""
return subs(string)
#cdef class subs(str):
# pass
#def csub(string):
# return csubs(string)
@cython.test_fail_if_path_exists("//SimpleCallNode")
@cython.test_assert_path_exists("//PythonCapiCallNode")
def typed(str s):
"""
>>> print(typed(None))
None
>>> type(typed(None)) is type(typed(None))
True
>>> print(typed('abc'))
abc
>>> type(typed('abc')) is type(typed('abc'))
True
"""
return str(s)
@cython.test_fail_if_path_exists(
"//SimpleCallNode",
"//PythonCapiCallNode",
)
def typed_not_none(str s not None):
"""
>>> print(typed('abc'))
abc
>>> type(typed('abc')) is type(typed('abc'))
True
"""
return str(s)
|