Skip to content

Tag: python

Mongo db array of images change schema

I have an array of images in mongodb and I am trying to change the schema of the array. Right now the images are stored like bellow And the final output I want is like bellow. How can I do this in mongosh? Is it easier to do this as a Python Array and then import back to mongodb? Thank

How to have an incomplete block in Python without error?

This is my code which logically throws error that needs indentation: elif platform == ‘win32’: IndentationError: expected an indented block I need Python to check if OS is whether Linux or Windows, open the file in home of that user and do the same code (in this case for loop) after detecting the …

How to use patch.object() correctly

I’m trying to get my head around Mock and patch(), but I’m stuck on a somewhat simple example. Say I have the following function in main.py, which tests if it’s a weekday or not. I want to run my test with two possible outcomes: either False if I mock Saturday or Sunday or True if it’s…

for loop with zip in python

I want to use zip to iterate to existing Lists. I did that with the code below. Currently the output is just Name –> Name. How do I use the new creates list or if that’s not possible the other lists to print following sentence: “#NAME is #AGE years old, and they can be called at #NUMBER”. Is it…