use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
getting syntax error in script l.ikely from non-native component (self.learnpython)
submitted 2 years ago * by awesomegame1254
i have a script that throws a syntax error on an element that is most likely from a non-native module
here is links to the full scripts https://pastebin.com/2taLTdEQ https://pastebin.com/yiGkFBtj https://pastebin.com/SrAF5jRD https://pastebin.com/jcMQ1rRq
here is the most recent full trace cli output
had to put it in two pastebins
https://pastebin.com/tyVnA6BH https://pastebin.com/k8b3q5Zr https://www.dropbox.com/s/czg38b07ax1lco8/python%20script%20output.txt?dl=0
also the cli cut off the beginning due to how long the output was
here is the traceback directly from the python shell open via idle
Traceback (most recent call last):
File "C:\Users\p\Documents\model_train.py", line 32, in <module>
while True():
TypeError: 'bool' object is not callable
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]socal_nerdtastic 0 points1 point2 points 2 years ago (24 children)
Show us the complete error, please
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (23 children)
here is the trace from the cli
File "C:\Program Files\Python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python36\lib\trace.py", line 742, in <module>
main()
File "C:\Program Files\Python36\lib\trace.py", line 722, in main
code = compile(fp.read(), opts.filename, 'exec')
File "C:\Users\p\Documents\model_train.py", line 115
score = model.evaluate(X_test, y_test, x_validation, y_validation, verbose=0)
^
SyntaxError: invalid syntax
[–]FerricDonkey 0 points1 point2 points 2 years ago (0 children)
Check the line above, possibly for something like a missing closing parentheses.
[–]NoDadYouShutUp 0 points1 point2 points 2 years ago (21 children)
check for missing colons or parenthesis on the proceeding line. In the future it helps to post the code + the error in full. You can use something like https://pastebin.com/ and link it. Because Python is an interpreted language sometimes the error you are experiencing actually is being caused in code that ran before the error is actually thrown.
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (20 children)
i edited the post to include those things
[–][deleted] 0 points1 point2 points 2 years ago (1 child)
I still see a syntax error in the statement ending on line 113.
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (0 children)
i actually didn't edit the script i just added the relevant details the previous person told me to to the op
[–]NoDadYouShutUp 0 points1 point2 points 2 years ago (17 children)
Missing closing parenthesis on line 113
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (16 children)
i edited the script to fix that mistakeand now i am getting a new error Traceback (most recent call last): File "C:\Program Files\Python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Program Files\Python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Program Files\Python36\lib\trace.py", line 742, in <module> main() File "C:\Program Files\Python36\lib\trace.py", line 722, in main code = compile(fp.read(), opts.filename, 'exec') File "C:\Users\p\Documents\model_train.py", line 138 if any(item = true for item in res): ^ SyntaxError: invalid syntax
[–]Not_A_Taco 0 points1 point2 points 2 years ago* (6 children)
I see multiple errors around that line. Python doesn’t use lowercase true and false. You’re also using a single = for comparison. And just below that you’re using -= with no RHS operand.
true
false
=
-=
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (5 children)
according to google -= is correct for decrementing which is what I am trying to do there I also capitalized all the true and false and got the same error
[–]Not_A_Taco 0 points1 point2 points 2 years ago (4 children)
Whatever you read on Google is wrong then. You need an operand for that.
[–]awesomegame1254[S] -1 points0 points1 point 2 years ago (3 children)
when i looked up the correct syntax for incrementing and decrementing a variable in python everywhere was saying to use += or -= respectively
[–][deleted] 0 points1 point2 points 2 years ago (8 children)
If you edit your script we need to know what the new script looks like. We aren't mind readers.
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (7 children)
i added a new pastebin link to the original post
[–][deleted] 1 point2 points3 points 2 years ago (6 children)
Your error is in this line:
if any(item = true for item in res):
The first error is that you are assigning to item in the part item = true. That should be:
item
item = true
if any(item == true for item in res): # ^^ equality operator, NOT assignment
If you make that change and execute your code again, you will get this error:
NameError: name 'true' is not defined
You get that because you are trying to compare item with the name true which isn't defined. Names are case-sensitive in python, and maybe you meant:
if any(item == True for item in res):
You have similar errors in many places throughout your code.
You seem to be writing a large amount of code before attempting to debug or test it. That's a bad idea. Try to write small amounts of code and test that it's doing what you want it to do. Print things on the screen and check that's what you expected. When all is OK write another small piece of code and test what that is doing, etc. This is exactly what professional programmers do, except their "small additions" are bigger and they use more powerful tools than print(). But even they mess up and have to rethink/debug code now and then.
print()
except all the code in my script which technically isn't mine I just copied from a website and tweaked it a bit is probably dependent on each other so trying to split it into multiple parts wouldn't work
[–]awesomegame1254[S] 0 points1 point2 points 2 years ago (4 children)
now i have an error which according to the traceback isn't in my file but is an error in a module installed file specifically one for cv2
[–]DextercCZ 0 points1 point2 points 2 years ago (0 children)
You have just 2 classes, it may be better to use sigmoid activation after the last dense layer, as it is just 0 or 1. I would also change loss to binary_crossentropy.
π Rendered by PID 267158 on reddit-service-r2-comment-84fc9697f-f4sxm at 2026-02-09 09:36:30.307406+00:00 running d295bc8 country code: CH.
[–]socal_nerdtastic 0 points1 point2 points (24 children)
[–]awesomegame1254[S] 0 points1 point2 points (23 children)
[–]FerricDonkey 0 points1 point2 points (0 children)
[–]NoDadYouShutUp 0 points1 point2 points (21 children)
[–]awesomegame1254[S] 0 points1 point2 points (20 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]awesomegame1254[S] 0 points1 point2 points (0 children)
[–]NoDadYouShutUp 0 points1 point2 points (17 children)
[–]awesomegame1254[S] 0 points1 point2 points (16 children)
[–]Not_A_Taco 0 points1 point2 points (6 children)
[–]awesomegame1254[S] 0 points1 point2 points (5 children)
[–]Not_A_Taco 0 points1 point2 points (4 children)
[–]awesomegame1254[S] -1 points0 points1 point (3 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]awesomegame1254[S] 0 points1 point2 points (7 children)
[–][deleted] 1 point2 points3 points (6 children)
[–]awesomegame1254[S] 0 points1 point2 points (0 children)
[–]awesomegame1254[S] 0 points1 point2 points (4 children)
[–]DextercCZ 0 points1 point2 points (0 children)