Syntax error: bad input '' in codeskulptor - python

Sometimes when I load a particular codeskulptor program that gives me the
error: Syntax error: bad token '' on a line of code, what is wrong?
Note: This is a different question, I know I asked a similar question before but this is a different issue.

I generally consider this as a bug in codeskulptor. When this happens, you probably copied that line of code, You could just delete and rewrite the exact same line of code. If it works then you're set, if it doesn't then there is a bug in your code but most likely won't be on that very line.

Related

Python SyntaxError: invalid syntax when implementing bbcodepy

I got bbcodepy and I'm allowed to modify it, but I can't import it in my main.py. I keep getting a SyntaxError and I don't really know what's wrong with the code because I didn't write it. I just want to tinker around a little bit and see if I can get it to fill my needs.
Here's an image pointing me in the direction of the syntax error. But I noticed the same code is written on the same line and I don't get the SyntaxError for that. Here's the code:
_URL_RE = re.compile(ur'''\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&|")*(?:[^!"#$%&'()*+,.:;<=>?#\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&|")*\)))+)''')
The problem appears to be "[^\s&()]" but only the second one, not the first one. If you look closely in the code you'll see that the same thing appears twice, but I only get the SyntaxError on the second appearance. Someone enlighten me, please. I've been trying to find a decent BBCode parser for Python for a couple of days now and I believe this is the one I can modify to my needs. I can't seem to get bbcode to work as I want it to, so I'm trying this out.
Well, Python version 3.4 and above does not support a 'UR' prefix.
You need to execute your code with Python 2.7, or change to line into:
_URL_RE = re.compile(r'''\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&|")*(?:[^!"#$%&'()*+,.:;<=>?#\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&|")*\)))+)''')
See also: python version 3.4 does not support a 'ur' prefix
Note: consider avoiding triple-quoted string because if you insert a newline, it can change the meaning of the regex (unless it is compiled in VERBOSE mode).

SyntaxError when runing "python examples/train.py singleagent_ring"

When I run python examples/train.py singleagent_ring
I find the following error:
file "examples/train.py", line 201
**config
^
SyntaxError: invalid syntax
Please any help?
Yeah, I feel like if you added the code you were working on as well as well as the line of code where the error was found that would make this question easier to understand. Additionally, have you attempted to debug this issue on your own? If so, what did you try? Informing us of these things would make it much easier to get the full picture of the issue you've encountered.
Aside from that, a SyntaxError is usually associated with something being mistyped in the syntax of your code so you may want to look it over for any spelling errors, missing indents, and/or missing/extra characters in your code. That's the most I or anyone else here can really tell you without any more context.

shelve module even not creating shelf

I am new to stackoverflow and experimenting with Python, currently just trying tutorial examples. Experienced a wonderful learning curve but got completely stuck with the following (working under windows 10):
import shelve
s = shelve.open("test")
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\dbm\dumb.py", line 82, in _create
f = _io.open(self._datfile, 'r', encoding="Latin-1")
FileNotFoundError: [Errno 2] No such file or directory: 'test.dat'
It would be great to get some help to resolve this.
During handling of the above exception, another exception occurred:
In Python 3, by default, shelve.open tries to open an existing shelf for reading. You have to pass an explicit flag to create a new shelf if if doesn't already exist.
s = shelve.open("test", "c")
This is in contrast to Python 2, where the default flag was "c" instead of "r".
How to read an error message
In general, error messages will do their best to tell you what's wrong. In the case of python, you'll typically start at the bottom; here
No such file or directory: 'test.dat'
tells you exactly why the error's being thrown: test.dat doesn't exist.
Next you would read upward through the stack trace until we got to something that we either understood or had written recently, and we'd try to make sense of the error message from there.
How to troubleshoot an error
Is the stated problem intelligible?
Yes, we asked the software to do something with a (.dat?) file called "test", so we at least know what the hell the error message is talking about.
Do we agree with the underlying premise of the error?
Specifically, does it make sense that it should matter if test.dat exists or not? Chepner covers this.
Do we agree with the specific problem as stated?
For example, it wouldn't be weird at all to get such an error message when there was in fact such a file. Then we would have a more specific question: "Why can't the software find the file?" That's progress.
(Usually the answer would be either "Because it's looking in the wrong place" or "Because it doesn't have permission to access that file".)
Read the documentation for the tools and functions in question.
How can we validate either our own understanding of the situation, or the situation described in the error message?
Depending on the context this may involve some trial and error of re-writing our code to
print out (log) its state during execution
do something similar but different from what it was doing, which we're more certain should work.
do something similar but different from what it was doing, which we're more certain should not work.
Ask for help.
Seems shelve sometimes uses the dumbdbm to serialize.
Use dbm to use dbm instead:
import dbm
with dbm.open($filename, 'n') as db:
# read/write

Ride.py shows Calling method 'start_keyword' of listener XXX failed

I'm trying to run an automated test in Ride.py. This test works on my colleague's computer but for some reason does not work on mine. The test starts but at a certain point i get the following error:
[ ERROR ] Calling method 'start_keyword' of listener 'C:\Python27\lib\site-packages\robotide\contrib\testrunner\TestRunnerAgent.py' failed: IndexError: list index out of range
The interesting part is that this error occurs on the same spot ever time, but with a different test it happens at a different time.
I tried to google several things and nothing worked. One solution suggested there was a '#' commented somewhere and this caused the crash. I looked but I don't see a '#' commented anywhere.
Another suggestion lead me to believe my testrunneragent.py file must have been installed wrong. I went online to find the file and replaced it. This did not work either (reran the test before and after a restart of ride)
We tried to re-import the test files thinking perhaps something went wrong there. This did not help either.
Googling juts the last part (IndexError: list index out of range) gave me the suggestion it does not recognize all the lines of code in the back-end file. I would have no clue how to solve this as im not a major coder.
One difference between me and my colleague could be the versions. I downloaded python version 2.7.16 and ride 1.7.3.1. My colleague uses an older version of both python and RIDE. Perhaps the problem could be here?
https://paste.fedoraproject.org/paste/TLekH3az0m4wuUyM8C2RYw
I expect the test will run without failing (it is a happy flow) I have included some screenshots with code in the previous segment that might help
downgraded to the same version of Ride.py
This seems to have fixed the issue

Python - very ambiguous error message

I'm working on a large scale software system written in Python right now, which includes multiple modules. I was wondering what I should do about this, if anyone could make any sense of this error message that I keep receiving:
File "<string>", line 1, in <module>
NameError: name 'CerealObject' is not defined
The thing that makes it very cryptic is that it seems to not provide an actual file name or a specific module. From a beginner's standpoint this makes it seem impossible to debug.
File "<string>" in an exception stack trace typically means that you're using either exec or eval somewhere. They execute code from a string, hence the lack of an actual file name.
You'll need to look at the following line(s) of your stack trace to determine the source of the problem.

Categories

Resources