0

Append usually means saying "Start at the end of the file"

"+" is added in the mode parameter in open(filename, [mode], [buffering]) to allow both read and write operations

Now if I use "r+" it means "Start at the beginning and allow both read and write operations"

And for "a+" it should mean "Start at the end and allow both read and write operations" ; But this is not the case. For "a+" it starts at the beginning and allow read write operations.

So this means there is no difference between "r+" and "a+" .

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • possible duplicate of http://stackoverflow.com/questions/13248020/whats-the-difference-between-r-and-a-when-open-file-in-python – Lafexlos Mar 23 '14 at 15:46
  • possible duplicate of [python open built-in function: difference between modes a, a+, w, w+, and r+?](http://stackoverflow.com/questions/1466000/python-open-built-in-function-difference-between-modes-a-a-w-w-and-r) – jonrsharpe Mar 23 '14 at 16:09

1 Answers1

0

Basically, a+, reads from beginning but writes to the end and a+ will create the file if it does not exist.

Since opening file in Python is almost identical in C you can take a look at this.

Lafexlos
  • 7,618
  • 5
  • 38
  • 53