Lua for Python Programmers

Strings

If you fell in love with Python when you learned about “slicing” strings (and lists), Lua has little chance of stealing your heart. In many languages, a string is like an array of characters. A Python string is essentially an immutable list. Sadly, Lua strings do not have a character extraction or substring operator. On the bright side, the function which performs substring operations in Lua has some similarities to Python slicing. The major differences are the starting value for indices and the requirement of parameters. Python wins a gold medal in writability here. Lua can’t even compete in the extract-a-character division of this comparison. But with the same ingenuous use of negative numbers, Lua maintains some stature in the realm of substrings.