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

Compatibility issue between argparse and pythonnet packages #404

Closed
@sg08013

Description

@sg08013

Environment

  • Pythonnet version: 2.3.0.dev1 (built from master on 23/02/2017)
  • Python version: 2.7.13 64bit
  • Operating System: Windows 7 64bit

Details

  • I tested the pythonnet version from yesterday, 23/02/2017, as we are interested in the bug fix for the method overload issueMethod overload object type #377. I noticed that we are now running into compatibility issues with the package argparse.

The package argparse now only works correctly, if the parsing of the command line arguments is done BEFORE the import statement of pythonnet (import clr).

If I revert my pythonnet version to pythonnet==2.2.2, then the problem disappears.

The following minimal test code illustrates the problem:

file: test.pyimport argparse# import clr # can't put it here, args.arg1 will be Noneparser = argparse.ArgumentParser()parser.add_argument('--arg1', '-a', help='argument 1', dest='arg1')args = parser.parse_args()import clr   print('Argument 1 = ')print(args.arg1)

Then I start the script from command line as

python test.py --arg1 "Hello World"

If I run the code with the "import clr" statement after the call to parser.parse_args() then I get the desired output: Argument 1 =hello worldHowever, if I put the "import clr" at the beginning of the file, I get the output:Argument 1 =None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp