Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rewrite parse_intermixed_args() in argparse #125355

Closed
Assignees
serhiy-storchaka
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement
@serhiy-storchaka

Description

@serhiy-storchaka

parse_intermixed_args() andparse_known_intermixed_args() are implemented by parsing command lines twice -- first only optional arguments, then the remaining is parsed as positional arguments. This approach has some issues.

  • The parser is temporary modified to suppress positional or required optional arguments in these two stages. This is not good, because the parser can no longer be used concurrently. This also smells bad in general, this can hide some bugs.
  • Default values are handled twice.
  • Unknown options inparse_known_intermixed_args() cannot be intermixed with positional arguments. Well, "parsing only known arguments" is a dubious feature, but still...

I tried to rewrite the implementation by moving the code deeper. No longer parser patching, defaults are handled only once, unknown options are excluded from positionals parsing.@hpaulj,@bitdancer, as the authors of the original implementation, could you please review this code?

Linked PRs

Metadata

Metadata

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

Status

Doc issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp