ngangsia akumbo wrote: > error > > yems ~ # nano testfile1 > yems ~ # python testfile1 > Enter file name: g > write in data: g > Traceback (most recent call last): > File "testfile1", line 11, in <module> > file.write(file1) > TypeError: function takes exactly 1 argument (0 given) > > > > import os.path > > save_here = '/home/yems/newfile/' > file_name = raw_input("Enter file name: ") > filesname = os.path.join(save_here, file_name+".txt") > > file1 = open(filesname, 'w') > > file_data = raw_input('write in data: ') > > file.write(file1) > > file1.close()
file is a built-in type and file.write(file1) is roughly equivalent to file1.write() The latter is the preferred way to invoke the method; thus the (confusing) error message > TypeError: function takes exactly 1 argument (0 given) is trying to convey that you are not providing any data to write. The correct call instead of > file.write(file1) is then file1.write(file_data) -- https://mail.python.org/mailman/listinfo/python-list