isaacg1 / pyth

Pyth, an extremely concise language. Try it here:
https://pyth.herokuapp.com/
MIT License
263 stars 57 forks source link

Eval Leading Zero Error #172

Closed benstopics closed 8 years ago

benstopics commented 8 years ago

literal_eval does not evaluate numbers with leading zeros.

ex. => v"08" yields => Traceback (most recent call last): File "pyth.py", line 683, in <module> File "<string>", line 3, in <module> File "/app/.heroku/python/lib/python3.4/ast.py", line 46, in literal_eval File "/app/.heroku/python/lib/python3.4/ast.py", line 35, in parse File "<unknown>", line 1 08 ^ SyntaxError: invalid token

isaacg1 commented 8 years ago

This is true, so? It's intended behavior.

benstopics commented 8 years ago

I don't understand how this is helpful. If the string is clearly all digits, why would you use a leading zero to prevent the string from being invalidated? You would use some other character.

isaacg1 commented 8 years ago

So you want v to work like s on strings of digits? Sounds reasonable.

benstopics commented 8 years ago

I would like to golf Project Euler challenges and # 11 provides a 20x20 grid of numbers all two digits (the single digit values having a leading zero). It was easy to just regex remove the leading digits, but I think it would look cleaner without having to use regex. If this shouldn't be a behavior of r<str>7, then maybe a new mode would be helpful, even r<str>-7 r<str>_7. I'm not sure if using negative numbers for mode changers has been considered or is practical.

isaacg1 commented 8 years ago

I see the point. Yeah, that's probably worth changing. Will do.

isaacg1 commented 8 years ago

Fixed.