Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:22:49+00:00 2026-06-05T15:22:49+00:00

syntax error: msg = keyword can’t be an expression offset = None print_file_and_line =

  • 0

syntax error:

msg = "keyword can't be an expression"
      offset = None
      print_file_and_line = None
      text = 'data = data(name and mood=self.request.POST)\n'

I’m posting much of the code here as even though my Datastore has a “Visitor” Entity with name, mood, date properties (the index.yaml file is working apparently), form data is not being submitted to Datastore as evident in Console query:

SELECT name FROM Visitor
              ^ SyntaxError: invalid syntax

The last section of the following is me guessing what to do from modified Google tutorial. I know it’s wrong but hope you see what I’m trying to do:

class Visitor(db.Model):

    name = db.StringProperty(required=1)
    mood = db.StringProperty(choices=["Good","Bad","Fair"]) # this is Radio button
    date = db.DateTimeProperty(auto_now_add=True)

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.out.write("""<html><body>
        <form action="/" method="post">
            <p>First Name: <input type="text" name="name"/></p>   # text
            <p><input type="radio" name="mood" value="good">Good</p>  # radio button v 
            <p><input type="radio" name="mood" value="bad">Bad</p>
            <p><input type="radio" name="mood" value="fair">Fair</p>
            <p><input type="submit"value="Process"></p>
        </form></body></html>""")  
    def post(self):
        name = self.request.get("name")
        mood = self.request.get("mood")
        data = data(name and mood=self.request.POST) # < < ^ ^ PROBLEM(S)
        if data.is_valid():
            Visitor = data.save(commit=False)
            Visitor.put()

thanks in advance for help to attain desired goal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:22:50+00:00Added an answer on June 5, 2026 at 3:22 pm

    Your problem is at this line as you’ve pointed out

    data = data(name and mood=self.request.POST) 
    

    The syntax error is because you’re trying to do assignment in an expression.

    mood=self.request.POST
    #"name and mood" is a logical expression which will return 
    #"mood" if bool(name) is True and bool(mood) is True
    #Otherwise it returns the first False value.
    data=data(name and mood)  
    

    Of course, this is funny too because data is presumably a callable which you’re replacing with it’s result…

    Also, data isn’t defined anywhere (that we can see)…So while we’ve gotten rid of one syntax error, there are (likely) other problems lurking in your script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a syntax error with this access query, but I can't see what
This query gives me syntax error in when-between line. how can i solve them?
Error msg: You have an error in your SQL syntax; check the manual that
Can anyone see my syntax error? The jsTree just wouldn't render. plus a strange
Parse error: syntax error, unexpected '?' error points to after .css : echo '<fb:recommendations
Why it's a syntax error: my @hash{1..4}=(1..4); but not this one: my %hash; @hash{1..4}=(1..4);
I get a syntax error in Python 2.7.3 like so: [s += 'Orig' for
This code shows syntax error in the parameter declaration.. Pls help me to solve
I'm getting $ syntax error, unexpected keyword_class, expecting keyword_do or '{' or '(' in
I am getting syntax error with the following statement REPLACE INTO users (screenname, token,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.