diff options
author | Thomas Waldmann <tw AT waldmann-edv DOT de> | 2011-03-27 01:16:28 +0100 |
---|---|---|
committer | Thomas Waldmann <tw AT waldmann-edv DOT de> | 2011-03-27 01:16:28 +0100 |
commit | b40e9c0629e03ee616ddec30f687b0455a56c217 (patch) | |
tree | 0c5054724c434070601c36c453ec2da426de7d17 /argparse.py | |
parent | 6d56abca3bb1a09184b48c06c9575fd4c3f3f519 (diff) | |
download | argparse-b40e9c0629e03ee616ddec30f687b0455a56c217.tar.gz |
make most tests work on python 2.3
Diffstat (limited to 'argparse.py')
-rw-r--r-- | argparse.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/argparse.py b/argparse.py index 36e54c4..3457867 100644 --- a/argparse.py +++ b/argparse.py @@ -93,10 +93,22 @@ from gettext import gettext as _ try: set except NameError: - # for python < 2.5 compatibility (sets module is there since 2.3): + # for python < 2.4 compatibility (sets module is there since 2.3): from sets import Set as set +try: + sorted +except NameError: + # for python < 2.4 compatibility: + def sorted(iterable, reverse=False): + result = list(iterable) + result.sort() + if reverse: + result.reverse() + return result + + def _callable(obj): return hasattr(obj, '__call__') or hasattr(obj, '__bases__') |