In this example, the expectation is that I ought to be able to read back exactly what I put into the file. What I actually get back is an empty file.
It occurred to me that this might actually be an expected behavior, and that perhaps there is a manual technique that allows me to flush the file?
CODE: SELECT ALL
Code: Select all
Micro Python v1.3.3 on 2014-10-02; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import os
>>> os.listdir()
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py', '.Trash-1000']
>>> open("foo.txt", "w").write("hello world")
11
>>> os.listdir()
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py', 'foo.txt', '.Trash-1000']
>>>
>>> open("foo.txt").read()
The use case here, is that I want to do stuff like:
* Periodically record something to a local text file, either in pyboard memory or on the SD card.
* As part of a code deployment process, automatically generate ,py files on the pyboard which can then be executed.
thanks
alexsunny