summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/builtin_ord.py
blob: 1556970ee3f945d70aad6cd8cebb04bcebf2ce38 (plain) (blame)
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
# test builtin ord (whether or not we support unicode)

print(ord('a'))

try:
    ord('')
except TypeError:
    print("TypeError")

# bytes also work in ord

print(ord(b'a'))
print(ord(b'\x00'))
print(ord(b'\x01'))
print(ord(b'\x7f'))
print(ord(b'\x80'))
print(ord(b'\xff'))

try:
    ord(b'')
except TypeError:
    print("TypeError")

# argument must be a string
try:
    ord(1)
except TypeError:
    print('TypeError')