Category: Python

Check if two dictionaries have same keys in python

I was lazy loading a large json file and wanted to collect only two keys. Running through with ujson I had to check that I had the correct data. I needed to check if my tmp dict was what I

Tagged with:

Change a value with configparser for python

configparser is a great module to store configuration information into a file a config file could look like this: To load the value from the file To change the value in the file:

Tagged with:

Dictionary changed size during iteration while using pop() in python

Running through a json file remove all keys but one This is fine running python2 but in python3 you will run into this error Calling keys() in python2 makes a copy of the keys that we iterate through. This is

Tagged with:

Remove non letter characters before and after characters in Python

To remove none letters characters from the beginning and end in python use regex from the library. I needed it to remove spaces as well but not in between the words. Here’s what I did: Output:

Tagged with:

AWS Lambda – name ‘Key’ is not defined

When going through the example from I ran into the following error message: The error come from this line The issue was that I was only importing boto3, this is not enough. Guess I have to read the whole