Python versus BoneScript on Your BeagleBone - dummies

Python versus BoneScript on Your BeagleBone

By Rui Santos, Luis Miguel Costa Perestrelo

You probably feel relatively comfortable with programming in BoneScript on your BeagleBone. In many ways, Python and BoneScript are similar. In both languages, you use variables, as well as if and while statements, and you also control the BeagleBone’s pins by changing the values of an object. But you need to be aware of some key differences:

  • The flow of code is different. Python’s interpreter runs each line sequentially. Two programs, one in BoneScript and another in Python, that do the same thing may end up being quite different.

  • Indentation is not just organization. Although you should indent your code as much as possible when you program in BoneScript, indentation is merely a tool — albeit a powerful one — to keep your program organized.

    In fact, you could write an entire program in a single line of code. In Python, however, indentations tell the interpreter which parts of the code are inside statements such as if and for.