t534.py 323 B

123456789101112131415161718
  1. class U(object):
  2. def __repr__(self): return "<U>"
  3. def __pos__(self): return 'pos'
  4. def __neg__(self): return 'neg'
  5. def __invert__(self): return 'invert'
  6. print U()
  7. print -(U())
  8. print +(U())
  9. print ~(U())
  10. class E(object):
  11. def __repr__(self): return "<U>"
  12. try: print +E()
  13. except TypeError: print 'no +'