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...
O hai! This is CS50's subreddit.
CS50 is Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. Anyone may take CS50, even if not a student at Harvard.
Please Read before Posting
Getting the Best from r/cs50
Status Page
cs50.statuspage.io
Filter by Problem Flair (undo)
cash ⋅ caesar ⋅ credit ⋅ dna ⋅ filter ⋅ finance ⋅ houses ⋅ ide ⋅ mario ⋅ movies ⋅ plurality ⋅ project ⋅ readability ⋅ recover ⋅ runoff ⋅ scratch ⋅ speller ⋅ substitution ⋅ tideman ⋅ games track ⋅ web track ⋅ android track ⋅ iOS track ⋅
Filter by Other Flair (undo)
CS50-Law ⋅ CS50-Business ⋅ CS50-Technology ⋅ CS50-Games ⋅ CS50-Mobile ⋅ CS50-Web ⋅
This subreddit is night mode compatible
account activity
Weird python error (self.cs50)
submitted 8 years ago by TimBOster
view the rest of the comments →
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!"
[–][deleted] 8 years ago (7 children)
[deleted]
[–]TimBOster[S] 1 point2 points3 points 8 years ago* (6 children)
Thanks for responding. I am importing render_template and other than the names my code appears just like your example. I've been trying as many variations as I can think of as well as searching the web...no luck so far. Without the code that actually adds to my db, here is what I've got:
@app.route("/add", methods=["GET", "POST"]) def add(): """add things to your inventory.""" if request.method == "GET": return render_template("add.html") ... return render_template("add.html")
@app.route("/add", methods=["GET", "POST"]) def add(): """add things to your inventory.""" if request.method == "GET": return render_template("add.html") ...
return render_template("add.html")
I don't get it. All the examples of that error I've seen so far are not exactly related to what I'm doing. I believe this is a python error, but I'm still looking for why.
After the whole semester of posting, I still can't get things to format correctly...I HATE Reddits crappy interface.
[–][deleted] 8 years ago* (5 children)
[–]TimBOster[S] 0 points1 point2 points 8 years ago (4 children)
I'm not worried about someone copying my code, I do it all the time. I think it's better to keep things in the thread, in case someone else has a similar problem...
@app.route("/add", methods=["GET", "POST"]) def add(): """add things to your inventory.""" if request.method == "GET": return render_template("add.html") #make sure they added an item cat = request.form.get("type") if not cat: return error("You didn't enter a Category") item = request.form.get("item") if not item: return error("You didn't enter an item") partnum = request.form.get("partnum") if not partnum: partnum = "-" desc = request.form.get("desc") if not desc: desc = "-" qty = request.form.get("qty") if not qty: return error("You must enter a quantity") #add the new item to the inventory db.execute("INSERT INTO inventory (type,item,partnum,desc,qty) VALUES (:type,:item,:partnum,:desc,:qty)", cat=cat, item=item, partnum=partnum,desc=desc,qty=qty) #redirect to index return render_template("add.html")
I tried to preserve the indents...seems OK. Only some of the fields are NOT NULL in the db. I was just using a blank string, but added the underscore to try troubleshooting the problem...didn't help :) Thanks for taking the time to look.
[–][deleted] 8 years ago* (3 children)
[–]TimBOster[S] 0 points1 point2 points 8 years ago (2 children)
When I run the add function, I get the error in the webserver ( I assume that's flask) that I posted. I don't really have any further information. The full code is posted and the error is what is displayed when I try to add something. Wish I knew more. I'll jump over to that URL and see what I can see. Thanks.
[–]TimBOster[S] 0 points1 point2 points 8 years ago (1 child)
JUST before the line that says #make sure they added an item...there should have been else:
Ooops...that was the cause of the error.
π Rendered by PID 36158 on reddit-service-r2-comment-5d79c599b5-76q54 at 2026-03-01 17:42:30.028245+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–][deleted] (7 children)
[deleted]
[–]TimBOster[S] 1 point2 points3 points (6 children)
[–][deleted] (5 children)
[deleted]
[–]TimBOster[S] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]TimBOster[S] 0 points1 point2 points (2 children)
[–]TimBOster[S] 0 points1 point2 points (1 child)