anvil.files Module

Classes

EditingContextManager

Context manager for editing data files.


Instance Methods

__enter__() → string

Begin editing the file.

__exit__()

End editing the file, uploading its new contents.


Files

Create a new ‘Files’ object

Constructor

Files()

Instance Methods

__getitem__() → string

Return the path of a file

editing(path) → anvil.files.EditingContextManager instance

Edit a file. To ensure the proper acquisition and release of the file, use the editing`` function in a withstatement e.g.with data_files.editing(’test.txt’) as file:`

    open(path, [mode="r"]) → anvil.files.OpenContextManager instance

    The open() function opens the file (if possible) and returns the corresponding file object.


      OpenContextManager

      Context manager for opening data files.


      Instance Methods

      __enter__() → File object

      Open the file.

      __exit__()

      Close the file, uploading its contents if it was opened for writing or appending.


      Globals

      data_files

      Access Data Files from the Data Files Service. To access a file stored in the Data Files Service use square brackets containing the path of the desired file - data_files['<file_path>'].



      Do you still have questions?

      Our Community Forum is full of helpful information and Anvil experts.


      anvil.files