I have a function that needs to lazy return file paths, but I can not actually use the file path since several python standard library functions perform explicit type checking on the arguments. So if I do the following:
lazy_path = lazy_object_proxy.Proxy(lambda: '/home/user')
os.path.join(lazy_path, 'dir')
It results in
/usr/lib/python3.8/posixpath.py in join(a, *p)
74 will be discarded. An empty last part will result in a path that
75 ends with a separator."""
---> 76 a = os.fspath(a)
77 sep = _get_sep(a)
78 path = a
TypeError: expected str, bytes or os.PathLike object, not Proxy
Is there any way to bypass this behavior, perhaps with monkey patching or so?
I have a function that needs to lazy return file paths, but I can not actually use the file path since several python standard library functions perform explicit type checking on the arguments. So if I do the following:
It results in
Is there any way to bypass this behavior, perhaps with monkey patching or so?