You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using the draw_text() function, I found I was regularly violating the preconditions of this function, which had not been communicated to me, producing the cryptic: IndexError: list assignment index out of range. I eventually figured out that my code was trying to draw strings that were too long and would exceed the rightmost boundaries of the screen.
Short term suggestions: The precondition (that text length and positioning must not exceed the width of the display) needs to be communicated in the function documentation.
Long term suggestions: Modify draw_text to be more resilient to strings that are "too long" by either:
Throwing a custom exception message that clearly communicates what the user has done wrong (e.g. IndexError: Provided string length and/or position exceeds rightmost edge of Display)
Catch the error and deal with it, throwing a warning instead. This would require a design decision to be made - Will text that exceeds the screen boundary be trimmed off? Or will there be some way to wrap text into a newline instead?
The text was updated successfully, but these errors were encountered:
While using the
draw_text()
function, I found I was regularly violating the preconditions of this function, which had not been communicated to me, producing the cryptic:IndexError: list assignment index out of range
. I eventually figured out that my code was trying to draw strings that were too long and would exceed the rightmost boundaries of the screen.Short term suggestions: The precondition (that text length and positioning must not exceed the width of the display) needs to be communicated in the function documentation.
Long term suggestions: Modify
draw_text
to be more resilient to strings that are "too long" by either:IndexError: Provided string length and/or position exceeds rightmost edge of Display
)The text was updated successfully, but these errors were encountered: