Permalink
Browse files

Support for Python 3.2.

  • Loading branch information...
1 parent a5ec786 commit 2ede5635e0b67b1ea5ae74932a26381f11f5828e @keleshev committed Apr 9, 2012
Showing with 9 additions and 7 deletions.
  1. +2 −0 README.md
  2. +5 −5 docopt.py
  3. +2 −2 example.py
View
@@ -98,6 +98,8 @@ is endorsed by [pep257](http://www.python.org/dev/peps/pep-0257/):
command properly, as well as a complete quick reference to all options and
arguments for the sophisticated user.
+`docopt` is tested with Python 2.6, 2.7 and 3.2.
+
API
===============================================================================
View
@@ -63,8 +63,8 @@ def __eq__(self, other):
return repr(self) == repr(other)
def __repr__(self):
- return 'Options(%s)' % ', \n '.join(["%s=%s" % (kw, repr(a))
- for kw, a in self.__dict__.items()])
+ return 'Options(%s)' % ',\n '.join(["%s=%s" % (kw, repr(a))
+ for kw, a in self.__dict__.items()])
def argument_eval(s):
@@ -81,16 +81,16 @@ def docopt(doc, args=sys.argv[1:], help=True, version=None):
''.join([d.short for d in docopts if d.short]),
[d.long for d in docopts if d.long])
except GetoptError as e:
- print e.msg
+ print(e.msg)
exit()
for k, v in getopts:
for o in docopts:
if k in o.forms:
o.value = True if o.is_flag else argument_eval(v)
if help and k in ('-h', '--help'):
- print doc,
+ print(doc.strip())
exit()
if version is not None and k == '--version':
- print version
+ print(version)
exit()
return Options(**dict([(o.name, o.value) for o in docopts])), args
View
@@ -25,8 +25,8 @@
def main(options, arguments):
- print options
- print 'Arguments:', arguments
+ print(options)
+ print('Arguments: %s' % arguments)
if __name__ == '__main__':

0 comments on commit 2ede563

Please sign in to comment.