Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python language issues #1616

Closed
ncassetta opened this issue Nov 17, 2018 · 5 comments
Closed

python language issues #1616

ncassetta opened this issue Nov 17, 2018 · 5 comments

Comments

@ncassetta
Copy link

ncassetta commented Nov 17, 2018

In Python language definition I found some inconsistencies:

"and", "not", "or" are treated as operators in Prism, but IDLE and WING101 (I don't know PyCharm) highlight them as keywords (I agree they should be operators, but this is the usage ...).
The definition seems to reflect Python2: "print" is treated as a keyword (in Python3 it is a builtin function) and "raw_input" (no more used in Python3) is highlighted. Perhaps Python2 and Python3 should have different definitions.
Thanks for your attention
N. Cassetta

@RunDevelopment
Copy link
Member

So, and, not, and or should be keywords (e.g. in VB does the same and it does look better as keywords). Ok, good point.

But splitting the (Prism) Python language?
I don't quite get the critique of raw_input. It's highlighted in Python2 and because it is not supported by Python3, nobody will use it, thus nothing is highlighted.
Are there a lot of case where Python2 and Python3 use the same syntax for different semantics? (I don't know python that well.)

@ncassetta
Copy link
Author

The only annoying thing should be print, which is a command in Python2 and a builtin function in Python3

# Python 2
s = 'mum'
print 'I love', s

and

# Python 3
s = 'mum'
print('I love', s)

In Prism print gets the same color of while, for etc, while (in Python 3) it should have the same of len abs etc.

@RunDevelopment
Copy link
Member

You could use the Highlight Keywords plugin to change the style of print depending on the Python version.

@ncassetta
Copy link
Author

Ok, thanks!
I have not tried all the plugins yet!

@RunDevelopment
Copy link
Member

I'm closing this now because without knowing the Python version of the code, it is impossible to when print is not a function.

Example:

print('foo')

It's impossible to tell from syntax alone whether it's Python 2 or 3.


As I state before:
You can change the highlighting of the print keyword specifically using the Highlight Keywords plugin and a bit of CSS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants