Skip to content

Tag: copy

Initialize deque efficiently

I am using a deque to store data that is going to be processed. The processing only starts when the deque is full so in a first step I fill my buffer the following way: However, when I do this and I modify one of the elements of my_deque, all elements of my_deque are modified. One alternative I found to

List change after copy Python

I’m coding the final part of a clustering program, I want to parse a file like where Example: I want to save all this information in different classes to process the data easier. Here is my code in python: For some reason, after the while loop, when I print all clusters objects, I see that all contains …

Tk Filedialog giving back a tuple

I am trying to take a file and put it into all directories 1 level down. I thought that this would be simple, what am I doing wrong? Answer Since it is “askopenfilenames”, it returns the results in the form of a tuple. You can iterate over it and move the files to the directory selected:

Numpy array not copy

I am working with numpy and images. I have a big image which i want to process bit by bit. So I want to create a reference to the original image, do something with it and move on. But when I change something in the frame the change does not transfer to the original, which is the opposite of everything

Python get filepath

I’m trying to create a simple script to copy the filepath of a selected file (in windows explorer) to the clipboard in python. I’ve been looking at pyperclip and tkinter but I’m unsure how exactly to proceed. The askopenfilename in tkinter seems promising, but I’d like to select the fi…

How can I make a deepcopy of a function in Python?

I would like to make a deepcopy of a function in Python. The copy module is not helpful, according to the documentation, which says: This module does not copy types like module, method, stack trace, stack frame, file, socket, window, array, or any similar types. It does “copy” functions and classes (shallow a…