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

Incorrect colon placement after semicolon #3118

Closed
H0R5E opened this issue Apr 18, 2016 · 3 comments
Closed

Incorrect colon placement after semicolon #3118

H0R5E opened this issue Apr 18, 2016 · 3 comments

Comments

@H0R5E
Copy link

H0R5E commented Apr 18, 2016

Description of your problem

What steps will reproduce the problem?

  1. Open Spyder
  2. Open a python file
  3. Write a one line if statement such as if True: print "Yes!";
  4. Press enter

What is the expected output? What do you see instead?

The semicolon should indicate that the if statement is finished and no colon in required.

Instead, Spyder places a colon after the semicolon giving something like this:

if True: print "Yes!";:

This will cause an invalid syntax error

Please provide any additional information below

Versions and main components

  • Spyder Version: 2.3.8
  • Python Version: 2.7.11
  • Operating system: Win64

Dependencies

Please go to the menu entry Help > Optional Dependencies (or
Help > Dependencies), press the button Copy to clipboard
and paste the contents below:

IPython >=1.0 : 4.1.2 (OK)
jedi >=0.8.1;<0.9.0: 0.9.0 (NOK)
matplotlib >=1.0 : 1.5.1 (OK)
pandas >=0.13.1 : 0.18.0 (OK)
pep8 >=0.6 : 1.7.0 (OK)
pyflakes >=0.5.0 : 1.1.0 (OK)
pygments >=1.6 : 2.1.1 (OK)
pylint >=0.25 : None (NOK)
qtconsole >=4.0 : 4.2.0 (OK)
rope >=0.9.2 : 0.9.4 (OK)
sphinx >=0.6.6 : 1.3.5 (OK)
sympy >=0.7.3 : 1.0 (OK)
zmq >=2.1.11 : 15.2.0 (OK)

@H0R5E
Copy link
Author

H0R5E commented Apr 18, 2016

I also noticed it happen with an "if" statement in a list comprehension split over two lines. The following will trigger an unwanted colon:

yes_list = [x for x in [None, None, None, "Yes!"]
                                                if x is not None]

@Nodd
Copy link
Contributor

Nodd commented Apr 19, 2016

You're right, this is a real problem. It has already been reported in #872, but nobody had the time to fix it yet.
I'm closing this one as a duplicate.

@H0R5E
Copy link
Author

H0R5E commented Apr 19, 2016

I don't know how, but for some reason, after 6 years of Python programming, I have always believed that a semicolon was required to terminate a single line if statement. Thank God for find and replace....

EDIT: In fact, thank God for "Find in files". This is an awesome feature and I use it a lot.

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