# uproot.WritableFile

Defined in [uproot.writing.writable](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/writing/writable.py) on [line 211](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/writing/writable.py#L211).

| **Inheritance order:**                                                             |
|------------------------------------------------------------------------------------|
| 1. [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md) |

### *class* uproot.writing.writable.WritableFile(sink, cascading, initial_directory_bytes, uuid_function)

* **Parameters:**
  * **sink** ([uproot.sink.file.FileSink](uproot.sink.file.FileSink.html.md)) – The physical layer for file-writing.
  * **cascading** (uproot.writing._cascade.CascadingFile) – The low-level file
    object.
  * **initial_directory_bytes** (*int*) – Number of bytes to allocate for new directories,
    so that TKeys can be added to them without immediately needing to rewrite
    the block.
  * **uuid_function** (zero-argument callable returning a `uuid.UUID`) – Function to
    create the file’s UUID and/or any directory’s UUID.

Handle to a writable ROOT file, usually created by [uproot.create](uproot.writing.writable.create.html.md),
[uproot.recreate](uproot.writing.writable.recreate.html.md), or [uproot.update](uproot.writing.writable.update.html.md) and
accessed through a [uproot.WritableDirectory](uproot.writing.writable.WritableDirectory.html.md).

<a id="uproot-writing-writable-writablefile-sink"></a>

## sink

#### WritableFile.sink

Returns a [uproot.sink.file.FileSink](uproot.sink.file.FileSink.html.md), the physical layer for writing
(and sometimes reading) data.

<a id="uproot-writing-writable-writablefile-initial-directory-bytes"></a>

## initial_directory_bytes

#### WritableFile.initial_directory_bytes

Number of bytes to allocate for new directories, so that TKeys can be added
to them without immediately needing to rewrite the block.

<a id="uproot-writing-writable-writablefile-uuid-function"></a>

## uuid_function

#### WritableFile.uuid_function

The function used to create the file’s UUID and/or any directory’s UUID.

<a id="uproot-writing-writable-writablefile-root-directory"></a>

## root_directory

#### WritableFile.root_directory

The root (first) directory in the file as a [uproot.WritableDirectory](uproot.writing.writable.WritableDirectory.html.md).

<a id="uproot-writing-writable-writablefile-update-streamers"></a>

## update_streamers

#### WritableFile.update_streamers(streamers)

Overwrite the TStreamerInfo in this file with a new list of [uproot.streamers.Model_TStreamerInfo](uproot.streamers.Model_TStreamerInfo.html.md)
or uproot.writable._cascade.RawStreamerInfo.

<a id="uproot-writing-writable-writablefile-close"></a>

## close

#### WritableFile.close()

Explicitly close the file.

(Files can also be closed with the Python `with` statement, as context
managers.)

After closing, objects cannot be read from or written to the file.

<a id="uproot-writing-writable-writablefile-closed"></a>

## closed

#### WritableFile.closed

True if the file has been closed; False otherwise.

The file may have been closed explicitly with
[close](#uproot-writing-writable-writablefile-close) or implicitly in the Python
`with` statement, as a context manager.

After closing, objects cannot be read from or written to the file.

<a id="uproot-writing-writable-writablefile-file-path"></a>

## file_path

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.file_path

Filesystem path of the open file, or None if using a file-like object.

<a id="uproot-writing-writable-writablefile-options"></a>

## options

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.options

The options passed to [uproot.create](uproot.writing.writable.create.html.md),
[uproot.recreate](uproot.writing.writable.recreate.html.md), or [uproot.update](uproot.writing.writable.update.html.md)
when opening this file.

<a id="uproot-writing-writable-writablefile-root-version"></a>

## root_version

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.root_version

Version of ROOT used to write the file as a string.

See [root_version_tuple](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-root-version-tuple) and
[fVersion](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-fversion).

<a id="uproot-writing-writable-writablefile-root-version-tuple"></a>

## root_version_tuple

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.root_version_tuple

Version of ROOT used to write teh file as a tuple.

See [root_version](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-root-version) and
[fVersion](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-fversion).

<a id="uproot-writing-writable-writablefile-is-64bit"></a>

## is_64bit

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.is_64bit

True if the file has 8-byte pointers in its header; False if the pointers are 4-byte.

<a id="uproot-writing-writable-writablefile-compression"></a>

## compression

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.compression

Compression algorithm and level ([uproot.compression.Compression](uproot.compression.Compression.html.md) or None)
for new objects added to the file.

This property can be changed, which allows you to write different objects
with different compression settings.

See also [fCompress](#uproot-writing-writable-writablefile-fcompress).

<a id="uproot-writing-writable-writablefile-hex-uuid"></a>

## hex_uuid

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.hex_uuid

The unique identifier (UUID) of the ROOT file expressed as a hexadecimal
string.

See [uuid](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-uuid) and
[fUUID](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-fuuid).

<a id="uproot-writing-writable-writablefile-uuid"></a>

## uuid

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.uuid

The unique identifier (UUID) of the ROOT file expressed as a Python
`uuid.UUID` object.

<a id="uproot-writing-writable-writablefile-fversion"></a>

## fVersion

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fVersion

Raw version information for the ROOT file; this number is used to derive
[root_version](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-root-version),
[root_version_tuple](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-root-version-tuple), and
[is_64bit](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-is-64bit).

<a id="uproot-writing-writable-writablefile-fbegin"></a>

## fBEGIN

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fBEGIN

The seek point (int) for the first data record, past the TFile header.

Usually 100.

<a id="uproot-writing-writable-writablefile-fend"></a>

## fEND

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fEND

The seek point (int) to the last free word at the end of the ROOT file.

<a id="uproot-writing-writable-writablefile-fseekfree"></a>

## fSeekFree

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fSeekFree

The seek point (int) to the `TFree` data, for managing empty spaces
in a ROOT file (filesystem-like fragmentation).

<a id="uproot-writing-writable-writablefile-fnbytesfree"></a>

## fNbytesFree

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fNbytesFree

The number of bytes in the `TFree` data, for managing empty spaces
in a ROOT file (filesystem-like fragmentation).

<a id="uproot-writing-writable-writablefile-nfree"></a>

## nfree

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.nfree

The number of objects in the `TFree` data, for managing empty spaces
in a ROOT file (filesystem-like fragmentation).

<a id="uproot-writing-writable-writablefile-fnbytesname"></a>

## fNbytesName

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fNbytesName

The number of bytes in the filename (`TNamed`) that is embedded in
the ROOT file.

<a id="uproot-writing-writable-writablefile-funits"></a>

## fUnits

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fUnits

Number of bytes in the serialization of file seek points, which can either
be 4 or 8.

<a id="uproot-writing-writable-writablefile-fcompress"></a>

## fCompress

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fCompress

Compression algorithm and level (as an integer code) for new objects added
to the file.

This property can be changed, which allows you to write different objects
with different compression settings.

See also [compression](#uproot-writing-writable-writablefile-compression).

<a id="uproot-writing-writable-writablefile-fseekinfo"></a>

## fSeekInfo

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fSeekInfo

The seek point (int) to the `TStreamerInfo` data, where
TStreamerInfo records are located.

<a id="uproot-writing-writable-writablefile-fnbytesinfo"></a>

## fNbytesInfo

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fNbytesInfo

The number of bytes in the `TStreamerInfo` data, where
TStreamerInfo records are located.

<a id="uproot-writing-writable-writablefile-fuuid"></a>

## fUUID

Inherited from [uproot.reading.CommonFileMethods](uproot.reading.CommonFileMethods.html.md).

#### WritableFile.fUUID

The unique identifier (UUID) of the ROOT file as a raw bytestring
(Python `bytes`).

See [hex_uuid](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-hex-uuid) and
[uuid](uproot.reading.CommonFileMethods.html.md#uproot-reading-commonfilemethods-uuid).
