Python - Overwriting an Existing File using Copyfile Methods

This is a pure python question -

I was using copyfile to move some files over to a temp, at the same time deleting the original, then moving the modified files in the temp back to the original folder.

I was wondering… Is there a python way to just overwrite during a file copy, so I can skip deleting the originals and moving back and forth between a temp folder?

You mean something like

  • read file
  • modify file
  • write file
    ?

No, I want to do something like:

copyfile("SameDir\OriginalFile.txt", "SameDir\OrginalFile.txt")

The problem is, an exception will raise because copyfile does not overwrite the original file.

Is there any Python method/fuction which will overwrite a file with the same name using a copy strategy?

(not read, write)

I don’t know how I do it…

But I found a work around. :slight_smile:

How much trouble is it using P3D for an online chat client only (with GUI of course)?

Will such a task require large amounts of code?

There already are such samples on the forums. First pick after a google search: [Multiplayer- with chat)

By the way, please open a new thread for a new topic and optionally mark this one as solved.

That doesn’t really answer my question, but no problem. I’m going to use a low level C programming to create an IM app and setup a chat server (like I did in the past). Man, it’s been several years since I coded in C, but when you start doing it…that knowledge comes flying right back. :smiley:

I was thinking about the graphic capabilities of Panda, but then realized I don’t need that much. Besides, I would rather compile all content into one little neat double click exe file, so there won’t be a need for a folder with mutiple files (or an installaion for that matter).

Both of my questions asked are related to each other but that would be hard to know without a certain amount of dirty programming under the belt. At the moment, I am not working on my Panda project because I have been tasked with something else. A little dirty work.

I’m going to HACK BABY!!!

:laughing:

Just kidding… I don’t know the first thing about hacking.

Best regards