Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks
NickleDave opened this issue Oct 12, 2024 · 1 comment

Comments

@NickleDave
Copy link
Collaborator

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
Copy link
Collaborator Author

... 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant