MattDMo / PythonImproved

The best Python language definition for Sublime Text - ever. Includes full support for Unicode, as well as both Python 2 and Python 3 syntax. Check out the Neon Color Scheme for highlighting.
https://packagecontrol.io/packages/Python%20Improved
MIT License
93 stars 11 forks source link

del is marked as a builtin function #28

Closed cknv closed 9 years ago

cknv commented 9 years ago

Please feel free to correct me, but currently, with python3 the del keyword gets scoped as a builtin function. The readme states that for python2 print and del is still a standalone keyword, but as far I as I am aware nothing changed for del in python3.

The scopes I see (via ScopeAlways) are:

It seems to me that del should be present in this line. And perhaps removed from here (and maybe here). Although I could be mistaken as I am not entirely familiar with the way the language file is generated, hence this not being a pull request.

To further illustrate my point, this is the output from a python3 repl:

>>> print
<built-in function print>
>>> del
  File "<stdin>", line 1
    del
      ^
SyntaxError: invalid syntax

To me this further reiterates that print is a function, while del is a keyword. The only keyword that seems to not raise a syntax error on its own is pass (which makes sense). Furthermore I tried testing if they were callable, print was, while del gives a syntax error (again).

For the record, I tried to coerce my code to be pretty with the function highlighting, by adding parenthesis around the target of del (basically treating it like a buildtin), but I realized that that was basically the same as putting parenthesis around the target of yield, return, or other keywords. In addition pylint also complained a fair bit about it with the superfluous-parens error.

If it was a conscious decision to make del scope as a function, I would certainly like to hear the reasoning for it.

Finally I would like to mention that I appreciate the work you have put into this, it makes it little bit nicer when writing python3.

MattDMo commented 9 years ago

Thanks for your feedback. I think you're correct, del should probably be scoped as keyword.other, the same as assert. I don't think I'll make a new release just for this, but I'll push the change to master, and you can copy the contents to PythonImproved.tmLanguage.