Click here to Skip to main content
15,304,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
from sys import argv
from os.path import exists

print(f"Copying from test.txt to copy-write.txt ")

# We could do these two on new line, how ?

in_file = open(test.txt)
indata =

print(f"The input file is {len(in_file)} long")

print(f"Does the output file exist? {exists(copy-write)}")

print('Ready , hit RETURN to continue , CTRL + C to abort')

out_file = open(copy-write, 'w')

print("Alright It,s done baby")


What I have tried:

i am getting a name error . the file i located i have gave the file location right but i am getting the this name is not defined
Updated 10-Dec-18 6:56am

1 solution

You need to put quotes around your file names in the open statements. They are names of files, not Python objects.

I suggest you go to The Python Tutorial — Python 3.7.1 documentation[^] and work your way through it a few times. You will learn much faster than posting basic questions here.
Member 14068174 10-Dec-18 20:51pm
Python docx is much boring
Richard MacCutchan 11-Dec-18 3:51am
Then maybe you should look for an alternative career.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900