filbert icon indicating copy to clipboard operation
filbert copied to clipboard

Python language problem with advanced indexes for strings

Open nemoyatpeace opened this issue 11 years ago • 5 comments

It appears that the python parser has issues with indexes for strings (and I would assume arrays as well). Using negative numbers and using slices doesn't seem to work.

Negative indexes:

message = 'Company Halt!'
if message[-1] != "!":
     order()

The order function should not run, but it does. When I change it to:

message = 'Company Halt!'
if message[len(message)-1] != "!":
     order()

The order function is not run.

Slices: message[:2] message[4:9] message[2:9:3]

None of these seem to work. (Though I only tested the first 2 methods).

So apparently python's extra ways of dealing with string indexing doesn't work.

nemoyatpeace avatar Jul 14 '14 00:07 nemoyatpeace

Python operations on strings are largely unsupported at the moment. We'll have to change that.

Negative indexes do not currently work, and are tracked in #22.

Slices should be working fine on lists and tuples. But, please let us know if you find issues with them.

You can test the Python parser outside of CodeCombat using this demo page: https://rawgit.com/differentmatt/filbert/master/test/interactive.html

Thanks for the feedback!

differentmatt avatar Jul 14 '14 16:07 differentmatt

OK, thanks, would love to see the python parser improved! Don't know that I could actually help with it other than debugging and letting you know when I find problems.

nemoyatpeace avatar Jul 14 '14 17:07 nemoyatpeace

Debugging and filing issues is very helpful, so thanks for that.

When you're ready to dig in and fix some issues, just let me know. I'm sure we can find some suitable tasks to get you started :)

differentmatt avatar Jul 14 '14 17:07 differentmatt

lambda doesn't seem to work either, but I'm assuming you already have that listed somewhere. Do you have a list of the things you are missing?

nemoyatpeace avatar Jul 14 '14 17:07 nemoyatpeace

Most of the unsupported keywords have issues filed, but if you don't see something there feel free to file a new issue. Lambda is tracked in #4.

differentmatt avatar Jul 14 '14 17:07 differentmatt