tf.compat.path_to_str
Stay organized with collections
Save and categorize content based on your preferences.
Converts input which is a PathLike
object to str
type.
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.
Args |
path
|
An object that can be converted to path representation.
|
Usage:
In case a simplified str
version of the path is needed from an
os.PathLike
object
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
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.compat.path_to_str\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 2 version](/api_docs/python/tf/compat/path_to_str) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/util/compat.py#L128-L164) |\n\nConverts input which is a `PathLike` object to `str` type.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.compat.path_to_str`](/api_docs/python/tf/compat/path_to_str), \\`tf.compat.v2.compat.path_to_str\\`\n\n\u003cbr /\u003e\n\n tf.compat.path_to_str(\n path\n )\n\nConverts from any python constant representation of a `PathLike` object to\na string. If the input is not a `PathLike` object, simply returns the input.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------|---------------------------------------------------------|\n| `path` | An object that can be converted to path representation. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `str` object. ||\n\n\u003cbr /\u003e\n\n#### Usage:\n\nIn case a simplified `str` version of the path is needed from an\n`os.PathLike` object\n\n#### Examples:\n\n \u003e\u003e\u003e tf.compat.path_to_str('C:\\XYZ\\tensorflow\\./.././tensorflow')\n 'C:\\XYZ\\tensorflow\\./.././tensorflow' # Windows OS\n \u003e\u003e\u003e tf.compat.path_to_str(Path('C:\\XYZ\\tensorflow\\./.././tensorflow'))\n 'C:\\XYZ\\tensorflow\\..\\tensorflow' # Windows OS\n \u003e\u003e\u003e tf.compat.path_to_str(Path('./corpus'))\n 'corpus' # Linux OS\n \u003e\u003e\u003e tf.compat.path_to_str('./.././Corpus')\n './.././Corpus' # Linux OS\n \u003e\u003e\u003e tf.compat.path_to_str(Path('./.././Corpus'))\n '../Corpus' # Linux OS\n \u003e\u003e\u003e tf.compat.path_to_str(Path('./..////../'))\n '../..' # Linux OS"]]