Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e5739144
Commit
e5739144
authored
Dec 12, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrapped a long line.
Converted to use "".startswith() to avoid slicing (& temp string creation).
parent
a78e66ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
Lib/getopt.py
Lib/getopt.py
+4
-3
No files found.
Lib/getopt.py
View file @
e5739144
...
...
@@ -68,7 +68,7 @@ def getopt(args, shortopts, longopts = []):
if
args
[
0
]
==
'--'
:
args
=
args
[
1
:]
break
if
args
[
0
]
[:
2
]
==
'--'
:
if
args
[
0
]
.
startswith
(
'--'
)
:
opts
,
args
=
do_longs
(
opts
,
args
[
0
][
2
:],
longopts
,
args
[
1
:])
else
:
opts
,
args
=
do_shorts
(
opts
,
args
[
0
][
1
:],
shortopts
,
args
[
1
:])
...
...
@@ -124,7 +124,8 @@ def do_shorts(opts, optstring, shortopts, args):
if
short_has_arg
(
opt
,
shortopts
):
if
optstring
==
''
:
if
not
args
:
raise
GetoptError
(
'option -%s requires argument'
%
opt
,
opt
)
raise
GetoptError
(
'option -%s requires argument'
%
opt
,
opt
)
optstring
,
args
=
args
[
0
],
args
[
1
:]
optarg
,
optstring
=
optstring
,
''
else
:
...
...
@@ -135,7 +136,7 @@ def do_shorts(opts, optstring, shortopts, args):
def
short_has_arg
(
opt
,
shortopts
):
for
i
in
range
(
len
(
shortopts
)):
if
opt
==
shortopts
[
i
]
!=
':'
:
return
shortopts
[
i
+
1
:
i
+
2
]
==
':'
return
shortopts
.
startswith
(
':'
,
i
+
1
)
raise
GetoptError
(
'option -%s not recognized'
%
opt
,
opt
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment