Skip to content

Tag: python

How can I open a folder with argparse

I want to open a folder containing x zipfiles. I have this code: But I get error code: PermissionError: [Errno 13] Permission denied: ‘Test’ I would like the zipfiles in the folder to be listed in an array when I run the code. Answer I’m not sure why you’re getting a permission error, …

How to add dotted or dashed line to png in Python?

Hello I want a draw a dashed or dotted line to png, I couldn’t find How can I do that, Can someone help ? im = Image.new(‘RGB’, (2000,2000),tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))) print(“…Saving…”) im.save(‘C:\Users\th3m1s\Desktop\Lejant\’+str…

Import module dynamically

I have a program that supports different communication protocols. The idea is, that the user chooses the protocol during startup and then the module supporting the respective protocol is imported. The function below populates the protocol module with all functions and variables from the user-chosen protocol. …

How to sum with condition in a Django queryset

I am trying to sum Django query with a condition. Suppose I have got some data like this: And these types are string and they have values, like x = 1, y = 25, z = -3 How can I sum up all the values without a loop? Currently using a loop. Answer To perform the calculation inside the database

Merge the matches from regular expressions into a single list

I am trying to separate a string in CamelCase into a single list I managed to separate the words with regular expressions But I am clueless on how create a single list of all the matches I tried to concatenate the lists, append something like that but I don’t think it would work in my case output: Desir…