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

Syntax Error: EOF while scanning triple-quoted string literal #541

Closed
sparseinference opened this issue Dec 10, 2016 · 6 comments
Closed
Labels
language specific Not universal in all languages wontfix

Comments

@sparseinference
Copy link

sparseinference commented Dec 10, 2016

Before version 1.3.0, in Python source, this was parsed as a multi-line comment and skipped over:

"""
Hello
"""

Now an error is reported on every new line in the comment.
It looks like it doesn't treat the entire triple-quoted string as a block.

@MichaelStetner
Copy link

I've been having this problem too, and it affects other multi-line statements. In all of the following examples, I have the cursor at the beginning of the first line and push Ctrl+Enter.

For example, the following causes an error:

print(
    "hello"
)

Error message:

File "<ipython-input-8-5d8744617373>", line 2
    "hello"
           ^
SyntaxError: unexpected EOF while parsing

It works if I indent the closing parenthesis, like this:

print(
    "hello"
 )

Same for triple quoted blocks. This triple quoted block evaluates just fine:

"""
 hello
 """

It seems like Hydrogen is detecting multi-line statements based on indentation only, not parentheses or triple quotes.

@lgeiger lgeiger added the language specific Not universal in all languages label Mar 19, 2017
@lgeiger
Copy link
Member

lgeiger commented Mar 19, 2017

From #77

Hydrogen relies on Atom's code-folding and indentation right now to figure out what a block is. This is so that the code for finding blocks works across languages.
This is definitely annoying behavior, but I don't know of a way to address this without writing a parser for each language that Hydrogen supports.

For now this needs to be fixed in Atom's language-python package.

@mohitv789
Copy link

mohitv789 commented Feb 21, 2019

I am getting this error while running following code: :(

# Hierarchical Clustering Code

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Mall_Customers.csv')
X = dataset.iloc[:, [3, 4]].values
y = dataset.iloc[:, 3].values

# Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)"""

# Feature Scaling
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
sc_y = StandardScaler()
y_train = sc_y.fit_transform(y_train)

# Using the dendrogram to find the optimal number of clusters
import scipy.cluster.hierarchy as sch
dendrogram = sch.dendrogram(sch.linkage(X, method = 'ward'))
plt.title('Dendrogram')
plt.xlabel('Customers')
plt.ylabel('Euclidean distances')
plt.show()

# Fitting Hierarchical Clustering to the dataset
from sklearn.cluster import AgglomerativeClustering
hc = AgglomerativeClustering(n_clusters = 5, affinity = 'euclidean', linkage = 'ward')
y_hc = hc.fit_predict(X)

# Visualising the clusters
plt.scatter(X[y_hc == 0, 0], X[y_hc == 0, 1], s = 100, c = 'red', label = 'Cluster 1')
plt.scatter(X[y_hc == 1, 0], X[y_hc == 1, 1], s = 100, c = 'blue', label = 'Cluster 2')
plt.scatter(X[y_hc == 2, 0], X[y_hc == 2, 1], s = 100, c = 'green', label = 'Cluster 3')
plt.scatter(X[y_hc == 3, 0], X[y_hc == 3, 1], s = 100, c = 'cyan', label = 'Cluster 4')
plt.scatter(X[y_hc == 4, 0], X[y_hc == 4, 1], s = 100, c = 'magenta', label = 'Cluster 5')
plt.title('Clusters of customers')
plt.xlabel('Annual Income (k$)')
plt.ylabel('Spending Score (1-100)')
plt.legend()
plt.savefig("plot_hc.png")

@kylebarron
Copy link
Contributor

kylebarron commented Feb 21, 2019

@mohitv789 You have a random """ at the end of one of your lines

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)"""

@mohitv789
Copy link

@kylebarron Thanks!

@affonsoviccari
Copy link

i am getting this error with this code:

pilha=[]
j=len(pilha)
op=input("Digite um jogo de parenteses:")
print(op)

((())(

i=0
while i<len(op):
if op[i]== "(":
j+=1
pilha.append(j)
print(pilha)
elif op[i]==")":
if len(pilha)>0:
pilha.pop(-1)
print(pilha)
else:
print("Pilha vazia")
else:
print("Comando inválido")
i+=1
if len(pilha)!=0:
print("Erro")
else:
print("OK")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language specific Not universal in all languages wontfix
Projects
None yet
Development

No branches or pull requests

7 participants