Append mode not supported for files

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
randomhuman
Posts: 19
Joined: Mon Jun 09, 2014 1:54 pm

Append mode not supported for files

Post by randomhuman » Mon Jun 09, 2014 2:01 pm

It looks like append mode is not supported when opening files, I get this exception:

ValueError: invalid mode: 'a'

The code works fine if I use write mode, but obviously that clobbers the file, which is inconvenient. Is there a reason for this, or is it maybe an oversight?

--
Kevin

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Append mode not supported for files

Post by pfalcon » Mon Jun 09, 2014 5:32 pm

I wouldn't call it "by oversight", but rather, "by design" - being "Micro", all Python features cannot be implemented, certainly not at once. But any features actually needed by users, especially those we hardly can be worked around, and append mode is such - will get into queue to wait for being implemented, if reported to bugtracker: https://github.com/micropython/micropython/issues . When you submit report, please don't forget to specify which MicroPython port you use - for example, unix port does support append mode.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

randomhuman
Posts: 19
Joined: Mon Jun 09, 2014 1:54 pm

Re: Append mode not supported for files

Post by randomhuman » Mon Jun 09, 2014 9:00 pm

Ok I've created a bug report as you suggested: https://github.com/micropython/micropython/issues/676

Thanks for the feedback.

Post Reply