Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Multiline comments in Python doesn't compile #1200

Closed
sterfield opened this issue Jan 28, 2014 · 10 comments
Closed

Multiline comments in Python doesn't compile #1200

sterfield opened this issue Jan 28, 2014 · 10 comments

Comments

@sterfield
Copy link

OS : Debian testing
Lighttable version : 0.6.2 (64 bit) (binary version 0.8.4)
Python version : 2.7.6

How to reproduce :

  • create a new file "test.py" and open it in LighTable
  • create a multiline comment
'''  
This  
is a  
multiline  
comment  
'''
  • execute the file (CTRL + SHIFT + ENTER)

Current results : Stacktrace saying "SyntaxError: EOF while scanning triple-quoted string literal"

Expected results : normal compilation.

Note on Python comments:

Thanks !

EDIT :
Change the code block to correctly displayed the line break.
Change the shortcut to execute the file to CTRL + SHIFT + ENTER

@bilderbuchi
Copy link

Ctrl-Shift-Space doesn't do anything for me, maybe you meant Ctrl-Shift-Enter? Also, your "multi-line-comment" is not really multiline, maybe you meant this:

'''
This is a multiline comment 
''' 

Aside of that, I can reproduce this. Same comment in Ipython 1.1.0 (python 2.7.5) works:

In [1]: '''
   ...: This is a comment
   ...: '''
Out[1]: '\nThis is a comment\n'

@sterfield
Copy link
Author

You are right, for both of your comments.

The multiline code I've put in my issue was already with line break at every words, but it wasn't displayed correctly (due to the proximity of the bullet point).It's fixed now.

I've also change the shortcut, it's indeed CTRL + SHIFT + ENTER to execute the whole file.

Thanks,

@bilderbuchi
Copy link

FWIW, this also happens with triple-quotes using ". It's pretty annoying when you use code containing python docstrings

@ibdknox any idea what's going wrong here?

@ibdknox
Copy link
Member

ibdknox commented Feb 6, 2014

Not sure, we just delegate to python's ast tools, compile, and eval: https://github.com/LightTable/Python/blob/master/py-src/ltmain.py#L103

@sterfield
Copy link
Author

Did some quick test.
I've create a small file, using this :

import ast

string="""'''
This is a multiline comment 
'''"""

print string

a = ast.parse(string)
print a

And it's compiling normally, in Python CLI and in LightTable.

But as soon as I put the same comment directly in the source code, as this :

import ast


'''
This is a multiline comment 
'''

string="""'''
This is a multiline comment 
'''"""

print string

a = ast.parse(string)
print a

The execution in Python CLI is OK, but I've got the same stack trace in LightTable.

Thanks,

@antibios
Copy link

Same issue on Light table 0.6.5
We use docstrings in most procedures, so this makes it difficult to use light table's best feature.

@stleon
Copy link

stleon commented Jun 16, 2014

The same problem in Light Table 0.6.6

@gnbl
Copy link

gnbl commented Nov 22, 2014

Still present in "Light Table version 0.7.2, Binary version 0.8.4" w/ "Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32"

@ufechner7
Copy link

Could someone add the label "Python"? This would make it more visible.

@kenny-evitt
Copy link
Contributor

I created LightTable/Python#40 to replace this.

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

No branches or pull requests

9 participants