Edit: sample code https://replit.com/@JustinEzequiel/CoralFrighteningSign thanks to JustinEzequiel This is my current code. It outputs something like this (if D32489DJ) was the host name. I want to make it output something like How can I modify my code to make this possible? Snippet of file path all you have …
Install python shout module in windows 10 (python version 3.9)
I am trying to install python-shout module in windows 10 but it fails. In the ubuntu works well. Edit (06/10/2022): Here is what i have tried to build python-shout in native windows Only download libshout module files from here: Note that i download all the 14 dependencies + this package: winpthreads I rename…
Truncate sublists to the lowest length
I have: I want: Which is the list l with all sublists truncated to the lowest length found for the sublists in l. I tried: Which works but quite slow and long to write. I’d like to make this more efficient through list comprehension or similar. Answer With list comprehension, one-liner: Or: Output: We c…
Get field type of document field from firestore
Is it possible to get the field type of a field in a document? I want to create a function that looks something like this: Where field.type returns the type of the field. For example it should return something like this: Answer From the document snapshot, with document.get you can get the field value as an Ob…
Python missing data in body
Hello i’m using request to perform some http calls. The is a strange behaviour, the response should contain a list of items, but i only get one item. This is the result i get from Postman when performing the call: With this is the reponse i get in my script : this is how i perform the action : it’…
Python WinError 32 The process cannot access the file because it is being used by another process
I made a script that converts pdf files into jpgs and then puts those jpgs in a specific folder. The script works fine so far but, I keep getting an error in the VScode terminal that says : I tried closing the file before running but, it still does it Answer Your script starts by doing so the process running
Nested FOR loops – coding challenge
I am learning python using STEPIK and I am facing this: I want on every iteration of the inside for loop sum the values of predicted_growth list with the value of cases list, save it in some temporary variable and print it. Click on the link for the full challenge. This is my code so far: This is the output
Jupyter import Python function
I have the following folder structure The file foo.py contains In the jupyter notebook I have which gives a file not found error. What’s the cleanest way of fixing that? (If possible, I’d like to keep foo.py unchanged.) Answer You get this error because the path is relative to your working directo…
Passing kwargs to a base classs using python attrs library
I am using the attrs python library for a child class which inherits from a non-attrs base class. I’d like to expose all of the parent parameters to the child via kwargs but cannot figure out how to go about it with attrs. Basic example: I don’t have a huge amount of discretion over the parent cla…
Input line that accepts one and two variables without breaking?
I’m trying to create a “Inventory system” as a beginner proyect. I have a dictionary with string keys and integers values, and I want the program to ask the user what materials he wants to take, and how much of it. That question takes from the materials dictionary and adds it to the “i…