Skip to content

Tag: python

Flask POST request is causing server to crash

I am trying to make a simple api in Flask, the first step being getting the POST json data. (I just want to print it for now) This is my code and when I request /api with json data, it returns a 500 error. Any thoughts on why this is happening? The curl command: body.json: Answer First what you want

Check for camel case in Python

I would like to check if a string is a camel case or not (boolean). I am inclined to use a regex but any other elegant solution would work. I wrote a simple regex Would this be correct? Or am I missing something? Edit I would like to capture names in a collection of text documents of the format Edit2

How to close IPython Notebook properly?

How to close IPython Notebook properly? Currently, I just close the browser tabs and then use Ctrl+C in the terminal. Unfortunately, neither exit() nor ticking Kill kernel upon exit does help (they do kill the kernel they but don’t exit the iPython). Answer There isn’t currently a better way to do…

How do I index the 3 highest values in a list?

so i have these 2 lists: I have to find the 3 highest scores and tally these scores with their respective scorers in the name list, so that I can have new lists I’m thinking of indexing the highest scores, appending them into a list than using the index to tally these scores with the names. my question …

python RuntimeError: dictionary changed size during iteration

I have obj like this It should be expand to I wrote code below, splite by ‘.’, remove old key, append new key if contains ‘.’, but it said RuntimeError: dictionary changed size during iteration for k, v in obj.iteritems(): RuntimeError: dictionary changed size during iteration Answer L…

Map Reduce on timestamps

Mongodb Database: How can I Map-Reduce or aggregate on the above data to generate an output as: I am trying to write some code but its difficult to average on unsorted dates. Are there any built in functions averaging on time to do this? Answer You could do min/max on the dates like described here for numbers…