cuthbertLab / music21

music21 is a Toolkit for Computational Musicology
https://www.music21.org/
Other
2.13k stars 402 forks source link

Tiny doc clarification #1711

Closed MarkGotham closed 6 months ago

MarkGotham commented 6 months ago

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". ;)

gregchapman-dev commented 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.

ahankinson commented 6 months ago

Yeah, since Python 3.10 the error messages can suggest “did you mean” when calling a non-existent property or method.

MarkGotham commented 6 months ago

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