# tf.compat.path_to_str

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/util/compat.py#L143-L179) |

Converts input which is a `PathLike` object to `str` type.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.compat.path_to_str`](https://www.tensorflow.org/api_docs/python/tf/compat/path_to_str)

<br />

    tf.compat.path_to_str(
        path
    )

Converts from any python constant representation of a `PathLike` object to
a string. If the input is not a `PathLike` object, simply returns the input.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `path` | An object that can be converted to path representation. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `str` object. ||

<br />

<br />

<br />

<br />

| ## Usage ||
|---|---|
| In case a simplified `str` version of the path is needed from an `os.PathLike` object. ||

<br />

#### Examples:

    $ tf.compat.path_to_str('C:\XYZ\tensorflow\./.././tensorflow')
    'C:\XYZ\tensorflow\./.././tensorflow' # Windows OS
    $ tf.compat.path_to_str(Path('C:\XYZ\tensorflow\./.././tensorflow'))
    'C:\XYZ\tensorflow\..\tensorflow' # Windows OS
    $ tf.compat.path_to_str(Path('./corpus'))
    'corpus' # Linux OS
    $ tf.compat.path_to_str('./.././Corpus')
    './.././Corpus' # Linux OS
    $ tf.compat.path_to_str(Path('./.././Corpus'))
    '../Corpus' # Linux OS
    $ tf.compat.path_to_str(Path('./..////../'))
    '../..' # Linux OS