[Python-bugs-list] [ python-Bugs-420771 ] 'rw' option to open: is it a bug?

noreply@sourceforge.net noreply@sourceforge.net
Wed, 02 May 2001 10:11:49 -0700


Bugs item #420771, was updated on 2001-05-02 10:11
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=420771&group_id=5470

Category: Python Library
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'rw' option to open: is it a bug?

Initial Comment:
if you open a file with 'rw'

f = open('foo.bar','rw')
ie you will be able to read, but not write

Python 2.1 (#3, Apr 19 2001, 11:45:56) [C] on sunos5
Type "copyright", "credits" or "license" for more
information.
>>> f = open("foo.bar",'rw')
>>> f.read()
'HelloWorld\n'
>>> f.write("NotWhatIExpect")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 9] Bad file number
>>> 

However the rw does not seem to be a valid option, yet
no error is produced upon opening the file, rather
when the operation is attempted.

It seems that what is needed if you want
'rw' is 'r+'.

>>> f = open("foo.bar",'r+')
>>> f.read() 
'HelloWorld\n'
>>> f.write("ThisIsWhatIExpect")
>>> f.close()

Could therefore 'rw' signal an error? Or do the
same as 'r+'?

  

 

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=420771&group_id=5470