crowsetta icon indicating copy to clipboard operation
crowsetta copied to clipboard

Write `__repr__`/`__str__` for format classes that uses `reprlib` so a user can print to get something readable

Open NickleDave opened this issue 1 year ago • 1 comments

Right now if we just do something like

>>> import crowsetta
>>> birdsongrec = crowsetta.example('Annotation.xml')
>>> birdsongrec

the auto-generated __repr__ provided by attrs will dump out every annotation to stdout. This is technically correct but not very helpful

Might be good to

  • [ ] override the __repr__ for each class and use reprlib in it to get an abbreviated representation of attributes
  • [ ] possibly provide an even friendlier version with __str__? In some cases I think it might be good to have an almost human-readable summary of the annotations in the file, "TextGrid with 5 tiers" or something like that

NickleDave avatar Oct 12 '24 12:10 NickleDave

... I think having a __str__ that uses reprlib so that the convention is you print(annot) to get some more readable version might make the most sense

NickleDave avatar Oct 12 '24 13:10 NickleDave