Closed MarkGotham closed 6 months ago
I’m pretty sure that message is generated by Python itself, not music21. I see that exact wording in non-music21 code as well.
Greg
On May 15, 2024, at 2:03 AM, Mark Gotham @.***> wrote:
Problem summary
Erroneously calling for the pitch attribute on a rest raises:
AttributeError: 'Rest' object has no attribute 'pitch'. Did you mean: 'pitches'?
I.e., when you have an existential error by requesting a rest with a pitch, solve it by asking for more pitches. ;)
We could replace with something like:
AttributeError: 'Rest' object has no attribute 'pitch'. Only notes do. Did you perhaps call '.notesAndRests' when you meant '.notes'?
Not a priority; simply making a "note" here ... and now taking a "rest". ;)
— Reply to this email directly, view it on GitHub https://github.com/cuthbertLab/music21/issues/1711, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR6X47HPVZLIVL4JPXVBMDDZCMQHRAVCNFSM6AAAAABHXXELHCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI4TOMRYGY4DSNI. You are receiving this because you are subscribed to this thread.
Yeah, since Python 3.10 the error messages can suggest “did you mean” when calling a non-existent property or method.
Ah, ok good shout.
A design critique of either python, or music21, or perhaps both.
In any case, forces beyond our control ;). Let's call it an easter egg.
Closing
Problem summary
Erroneously calling for the pitch attribute on a rest raises:
AttributeError: 'Rest' object has no attribute 'pitch'. Did you mean: 'pitches'?
I.e., when you have an existential error by requesting a rest with a pitch, solve it by asking for more pitches. ;)
We could replace with something like:
AttributeError: 'Rest' object has no attribute 'pitch'. Only notes do. Did you perhaps call '.notesAndRests' when you meant '.notes'?
Not a priority; simply making a "note" here ... and now taking a "rest". ;)