diff options
author | Wendell Smith <wackywendell@gmail.com> | 2015-10-26 17:34:00 -0400 |
---|---|---|
committer | Wendell Smith <wackywendell@gmail.com> | 2016-04-06 22:17:40 -0400 |
commit | 5ac270b06e411dd0e13108ed5dafad31d5ab589d (patch) | |
tree | 7d3edfe92ad8d53b4db3155ce4fc6f02ee3c39fd /numpy/compat | |
parent | 537d35c2cf49cae0a496c37564fa282ec80e3695 (diff) | |
download | numpy-5ac270b06e411dd0e13108ed5dafad31d5ab589d.tar.gz |
ENH: Add support for pathlib.Path objects to save/load functions
Diffstat (limited to 'numpy/compat')
-rw-r--r-- | numpy/compat/py3k.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/compat/py3k.py b/numpy/compat/py3k.py index d95a362ca..992ea50e6 100644 --- a/numpy/compat/py3k.py +++ b/numpy/compat/py3k.py @@ -7,9 +7,13 @@ from __future__ import division, absolute_import, print_function __all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', 'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested', 'asstr', 'open_latin1', 'long', 'basestring', 'sixu', - 'integer_types'] + 'integer_types', 'is_pathlib_path', 'Path'] import sys +try: + from pathlib import Path +except ImportError: + Path = None if sys.version_info[0] >= 3: import io @@ -86,3 +90,10 @@ def asunicode_nested(x): return [asunicode_nested(y) for y in x] else: return asunicode(x) + + +def is_pathlib_path(obj): + """ + Check whether obj is a pathlib.Path object. + """ + return Path is not None and isinstance(obj, Path) |