iterator that works on python 2 and 3 (#1111)

This commit is contained in:
Michel Oosterhof 2019-05-06 17:00:40 +04:00 committed by GitHub
parent d5ca8321e4
commit 25eba0aab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -307,12 +307,15 @@ class shlex:
def __iter__(self):
return self
def next(self):
def __next__(self):
token = self.get_token()
if token == self.eof:
raise StopIteration
return token
# For Python 2.x
next = __next__
def split(s, comments=False, posix=True):
lex = shlex(s, posix=posix)