For some odd reason, it seems like __getattr__
changes the value of the item in unpredictable ways, with respect to specific characters.
Here's a complete runnable example:
class blah(object):
def __getitem__(self,item):
print(item)
print(list([ord(s) for s in item]))
def __getattr__(self, item):
print(item)
print(list([ord(s) for s in item]))
b=blah()
print("Index...")
b['ϕ']
print("__getattr__...")
b.ϕ
print("getattr()...")
getattr(b,'ϕ')
Which outputs:
Index...
ϕ
[981]
__getattr__...
φ
[966]
getattr()...
ϕ
[981]
(notice the character changed in the __getattr__
call and not in the others). it doesn't happen for all characters, for example
print("Index...")
b['θ']
print("__getattr__...")
b.θ
print("getattr()...")
getattr(b,'θ')
yields
Index...
θ
[952]
__getattr__...
θ
[952]
getattr()...
θ
[952]
Ideas?