raspberrypipress / official-raspberry-pi-beginners-guide-5e

Code and resources for The Official Raspberry Pi Beginner's Guide, 5th Edition from Raspberry Pi Press
44 stars 6 forks source link

[Errata]: Possible typo, missing space #7

Closed Rueful-Pi closed 4 months ago

Rueful-Pi commented 7 months ago

Contact Details

No response

What format of the book has this error? You may select more than one option.

Print

What language of the book has this error?

English (EN)

Page Number or Section

pg. 184

Detailed description

On page 184 there is printed "print("pitch {0} roll {1} yaw {2}".format(pitch, roll, yaw)" Should there be a space after the period and before "format"? I see on pages 195 & 197 the word "format' is printed in red unlike the previous occurrence. It is not obvious on pages 195 & 197 that there exists a space (caused by page size limitations, I'm sure), only that on those pages the word "format" is printed in red text. The only way I could get my code in Thonny to show red text for the word "format", was to put a space after the period (some clarification in the book could be helpful for beginners). Also, should there be commas after"pitch {0}", and "roll {1}", like on pages 195 & 197?

bjepson commented 6 months ago

Hi @Rueful-Pi,

It should not matter whether you add a space or not, and it is not essential that Thonny display it in red text. I suspect the difference between the text colours you see on Thonny and on the printed page is due to a difference in behaviour between Thonny and the syntax highlighting tool we use to format text in the book (pygments). We have attempted to make the colours as close as possible, but it appears that Thonny and pygments have different opinions about whether the word "format" should be highlighted. If your code works, then everything should be fine, but we may consider switching to f-strings in a future edition, which is more likely to be formatted the same in Thonny and the book.

The commas are a matter of preference, and while we did use the commas in one example and not in another, we may look into making them consistent in a future edition to eliminate the potential for confusion.