asked    Barbara     2018-10-22       python       39 view        1 Answer

[SOLVED] SyntaxError: multiple statements found while compiling a single statement

I'm in Python 3.3 and I'm only entering these 3 lines:

import sklearn as sk
import numpy as np
import matplotlib.pyplot as plt

I'm getting this error:

SyntaxError: multiple statements found while compiling a single statement

What could I be doing wrong?

Edit: If anyone comes across this question, the solution I found was to download Idlex and use its IDLE version, which allows multiple lines.

Screenshot: http://imgur.com/AJSrhhD

  1 Answer  

        answered    Clara     2018-10-22      

In the shell, you can't execute more than one statement at a time:

>>> x = 5
y = 6
SyntaxError: multiple statements found while compiling a single statement

You need to execute them one by one:

>>> x = 5
>>> y = 6
>>>

When you see multiple statements are being declared, that means you're seeing a script, which will be executed later. But in the interactive interpreter, you can't do more than one statement at a time.





Your Answer





 2018-10-22         Bernie

These two codes should do exactly the same thing, but the first one doesn't work as I expect

PythonPlease explain why these two codes work differently..Actually I am trying to make kind of AI where in initial generations the individuals will go in random directions. For keeping the code simple I have provided some random directions in Brain myself.There is an Individual class that gives a brain to the individual. It also has a function that returns a child with EXACTLY the same brain (means same directions to go in) as the parent.I have two codes:First: When some directions is changed in the parent, the same thing is changed in the child too (or if changed in child...
 python                     2 answers                     16 view
 2018-10-22         Bridget

how to get javascript class properties list

I have javascript this class :class Student { constructor(name, birthDate) { this.name = name; this.birthDate = birthDate; } get age() { return 2018 - this.birthDate; } display() { console.log(`name ${this.name}, birth date: ${this.birthDate}`); }}console.log(Object.getOwnPropertyNames.call(Student));The issue is that you're using Object.getOwnPropertyNames wrong. You don't need to use call on it, you just call it.* And you need to pass an instance of Student; the class object itself doesn't have any properties. The properties a...
 javascript                     1 answers                     19 view
 2018-10-22         Phoenix

Public types cant be declared in class modules

I want to create a function in a VBA (access) class module which returns a result type. Like this:Public Type CheckResult isOk As Boolean errorText As StringEnd TypePublic Function Check() As CheckResult ...end functionThis function is used in a lot of different places. But the compiler tells me, that it is not allowed to declare public types in class modules? Why is this? Where to put my Type instead? Should I create a new module just for this type? Or is it better to create a "AllTypes"-Module to put all Type-declarations in? As for the Why question:Class modules ...
 vba                     2 answers                     17 view