Skip to content
Snippets Groups Projects
Select Git revision
  • 5c34c2ff7f0c44ec9e1d77059162584c6bd99c92
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

open_append.py

Blame
  • open_append.py 511 B
    try:
        import uos as os
    except ImportError:
        import os
    
    if not hasattr(os, "remove"):
        print("SKIP")
        raise SystemExit
    
    # cleanup in case testfile exists
    try:
        os.remove("testfile")
    except OSError:
        pass
    
    # Should create a file
    f = open("testfile", "a")
    f.write("foo")
    f.close()
    
    f = open("testfile")
    print(f.read())
    f.close()
    
    f = open("testfile", "a")
    f.write("bar")
    f.close()
    
    f = open("testfile")
    print(f.read())
    f.close()
    
    # cleanup
    try:
        os.remove("testfile")
    except OSError:
        pass