Constantly getting '...:' instead of 'Out [#]:' in Python 3.7 (Spyder) - python

About 95% of the time I input something into my console (function of something, defined object, etc.) I don't get an output, instead, I get 3 dots, with a colon, as if it wants me to input something.
Often times I can just spam the variable into the console, and eventually instead of '...:', I'll get 'Out [###]:(thing I called)', but this is absolutely ridiculous.
I've never had this problem in 2.7. I've always used Spyder as my IDE.
I've done my research on here, asked around, but cannot solve this.
Thanks in advance :)
Screenshot of my problem
Another shot

I figured out the solution a couple months ago, I figured I would post it here for those who may be experiencing the same issue. Simply press Shift+Enter instead of just Enter, when inputting into Console. Stupidly simple solution. Thank you all again.

The python interpreter is expecting additional lines of code. Either you typed the wrong command or you made a mistake in what you typed. This will happen, for example, if you type part of a command and hit return. The interpreter is expecting the rest of the command.

Related

Python program works on Windows, but not on Linux

I know that this question has been asked before, but none of the solutions given there seemed to work for me. As the title suggests, I wrote a battleship game in python on Windows and it worked there, but when I tried to run it inside the Linux terminal, I'm getting an error I never got on Windows. Here's the code.
It loads up normally, but when I input the starting position it says NameError: name 'a0' is not defined for example. I tried putting !/usr/bin/python at the beginning, but nothing changed. I'm sorry if this is a duplicate or if I'm missing something really obvious, but I would really appreciate some help. Thanks in advance.
The error seems to be in the way you are accepting input from terminal. For accepting textual data (a0, R, L, U, D etc... ) you need to use
raw_input()
in place of input. Just replace input() with raw_input() and it will work on all platforms.

Python syntax switching between 2 and 3

I've recently started having a weird bug with my python scripts. It seems like it's syntax switches between python 2 and 3 randomly when running the script. For instance, I'll write a script using the input() command, and it'll work fine for a couple hours, then start giving me an error even if I don't change a single thing in the code, and want me to switch input() to raw_input() in order for it to work again.
And the same will happen in reverse. I'll write a code with raw_input() since it doesn't like input(), and a few hours later it'll make me switch it. It does this with all syntax, not just the inputs. The other main one is the print command. It'll switch between wanting parenthesis around the print statement, or not.
But when I run python --version, it always returns only Python 3.5.1. Anyone have a fix for this? It's getting annoying having to change my scripts every few times I run them.

How to hot swap the current file in python

I am trying to hot swap a file in python. I am creating a game that takes a really long time to load. But I don't want to reload it every time. I am trying to change some code while the programme is in runtime.
For example:
I want to change this:
while True:
print("Hello")
to this while in runtime:
while True:
print("Hello World")
I looked hot swapping up for python and all of them are answers that I am not looking for. All the other answers change modules. I want to change the current file. Like java in eclipse. Please help!
I want to change the current file. Like java in eclipse.
When you modify Java code in Eclipse, the code is not currently running. In reality, Eclipse has a Java compiler built-in, which attempts to compile your code as you type it. That's how Eclipse is able to give you such fast feedback about syntax errors and type errors in your code. But it can't give you any information about the runtime behaviour of your code (whether or not it produces the right answer), because it doesn't run the code! You need to press the Run button for that.
So I think the question you really want to ask is not "Can I dynamically modify Python code?" (the answer to that is "Yes, but it's complicated and has caveats and is not a good idea") but "Does there exist a Python IDE which can give me feedback about syntax errors while I type?" The answer to that is an emphatic "Yes!". There's an extremely comprehensive list of options in this answer.
You can use dynamic execution using exec function.
Store the code you want to execute in a string and change it during runtime.

Compiling in geany but not in terminal?

So I have been messing around with python with openCV the last couple of weeks and it has worked perfectly. My problem is when I took two desperate code script's and put them together it wouldn't compile. (I know Duh python white space (I fixed all of it,"I think")) It threw an error in the terminal with a line number. At this time I was using text editor in Ubuntu so I threw it into Geany to figure out what line. When I got there I couldn't pick out what the error was all of the indentation was that of the original code and it fitted with that of the rest of the loop it was nested in. So I tried to compile it in Geany and it didn't throw errors at all. I find this extremely weird because Geany is only an editor and it relies on outside compilers to compile the code. I am assuming that the terminal is using the same compilers too (though I know it must not now). I though maybe it has something to do with the library openCV because I am not including it in Geany. So I changed the variable name that was throwing things. After that it still threw the same error so I came here confused.
The error message I am getting is
http://imgur.com/1otMyeZ
My code is at
http://pastebin.com/HYKjnyyc
The part that is giving error is here
http://pastebin.com/6TyXs3uc
Your problem still goes back to the white space you were working on. Everything (except line 297 to the end) below:
# THE DEMO PROGRAM STARTS HERE
is indented, including your three global variables, which makes them appear to the compiler as part of the class Target, which takes the variables out of the global scope, so they are not defined. Remove the unnecessary indentation in that area.
EDIT:
Looking back at your code again, You may also have some indentation problems from the
# Function Definitions
at line 88 and down. From the way the functions are indented they appear to be part of the class, but from the way they are called they appear not to be.
You would find writing in python a lot less frustrating if you use a more standard approach to your indentation/white-space handling. Read this PEP for some best practices in that regard.

pydev - can someone please explain these errors

I am developing using PyDev in Eclipse. I have put in some comments in my code. I get wavy red lines underneath certain words. The program runs fine and there are no warnings mentioned. So what is the meaning of these wavy lines.
e.g.
#!/usr/bin/python - I get the line under usr and python
# generated by accessing registry using another script written in VBScript.
# The scripts can do the follwing things.
- I get wavy lines under the words registry and following.
I need these comments as I may run the module on its own later.
Thanks for the help.
Neil speaks the truth, except for telling you to turn it off -- spell check in comments is quite helpful -- those who come after will thank you for ensuring they can read your comments without trying to decode random spelling errors.
The lines are simply pointing out words your IDE thinks are spelled wrong. I don't know why it doesn't understand "registry", but you have, in fact, misspelled "following" (as "follwing"). Fix the latter, ignore the former (or add it to the dictionary, don't remember if there's a convenient mechanism for that There is! See Macke's helpful comment below.).
Might be this is just a spellchecker. You have a typo "follwing" instead of "following".

Categories