2015-04-04 17:05:30 -04:00
|
|
|
# test builtin ord (whether or not we support unicode)
|
|
|
|
|
|
|
|
print(ord('a'))
|
|
|
|
|
|
|
|
try:
|
|
|
|
ord('')
|
|
|
|
except TypeError:
|
|
|
|
print("TypeError")
|
|
|
|
|
2015-04-19 07:26:46 -04:00
|
|
|
# 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")
|
2015-09-03 18:06:18 -04:00
|
|
|
|
|
|
|
# argument must be a string
|
|
|
|
try:
|
|
|
|
ord(1)
|
|
|
|
except TypeError:
|
|
|
|
print('TypeError')
|