raspberrypilearning / getting-started-with-the-sense-hat

A Learn Resource for the Sense HAT
https://www.raspberrypi.org/learning/getting-started-with-the-sense-hat/
Other
16 stars 14 forks source link

Suggestion - pass variables into function #2

Closed bennuttall closed 7 years ago

bennuttall commented 9 years ago

I'd consider writing the following code:

ap.show_message("Astro Pi is awesome!!",scroll_speed=0.05,text_colour=[255,255,0],back_colour=[0,0,255]

like this:

# colours
yellow = (255, 255, 0)
blue = (0, 0, 255)

message = "Astro Pi is awesome!!"
speed = 0.05

ap.show_message(message, speed, text_colour=yellow, back_colour=blue)

The show_message line is much shorter and the whole thing is clearer.

Also you should use tuples (255, 255, 255) rather than lists [255, 255, 255] to denote a colour.

bennuttall commented 9 years ago

I've cleaned up much of the Python but left the lists in for now (many to change and you may have referred to them as lists). I know you build up the code through the worksheet but would you consider using more colour variables and passing them in as arguments so as not to create very long lines?