On Sunday, February 1, 2015 at 10:15:13 AM UTC+5:30, Ethan Furman wrote: > On 01/31/2015 07:16 PM, Steven D'Aprano wrote: > > > > But by default, Python will fallback on __repr__ if __str__ doesn't exist, > > or __str__ if __repr__ doesn't exist, or both. Or something. (I always > > forget what the rules are exactly.) > > If __str__ is missing, __repr__ is called. > > If __repr__ is missing, object.__repr__ (or some intermediate base class' > __repr__) is called. > > -- > ~Ethan~
The other day I was taking a class in which I was showing - introspection for discovering -- help, type, dir etc at the repl - mapping of surface syntax to internals eg. a + b ←→ a.__add__(b) And a student asked me the diff between dir([]) and [].__dir__() I didnt know what to say... Now surely the amount of python I dont know is significantly larger than what I know Still it would be nice to have surface-syntax ←→ dunder-magic more systematically documented -- https://mail.python.org/mailman/listinfo/python-list