summaryrefslogtreecommitdiff
path: root/numpy/compat/py3k.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/compat/py3k.py')
-rw-r--r--numpy/compat/py3k.py13
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)