我需要表示我的数据类型 PS 没有前导和结束引号。
(所以'+'变成+)
我尝试覆盖repr但无法弄清楚如何正确地做到这一点。我的问题:
class E: # Expression-Class
pass
class AE(E): # Arithmetic_Expression-Class
pass
class BO(AE): # Binary_Operation-Class
pass
class P(BO): # Plus-Class
operator = PS()
class PS: # Plus_Sign-Class
def __repr__(self):
return + # <- obviously raises an error
# how to return '+' string without the single quotes (so: '+' -> +)?