From 1c8eec3a0fb37779da6de8ecdea3ce18308fb39d Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 8 May 2012 12:56:04 -0400 Subject: [PATCH] python 2 and 3 #7 --- args.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/args.py b/args.py index c2133d1..dbf0fcc 100644 --- a/args.py +++ b/args.py @@ -9,10 +9,18 @@ This module provides the CLI argument interface for clint. """ import os +import sys from sys import argv from glob import glob from collections import OrderedDict +# Python 3 +if sys.version_info[0] == 3: + string_type = str +else: + string_type = basestring + + def _expand_path(path): """Expands directories and globs in given path.""" @@ -34,7 +42,7 @@ def _expand_path(path): def _is_collection(obj): """Tests if an object is a collection. Strings don't count.""" - if isinstance(obj, str): + if isinstance(obj, string_type): return False return hasattr(obj, '__getitem__')