wooey / clinto

This converts an assortment of python command line interfaces into a language agnostic build spec for usage in GUI creation.
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

Having both the argparser and the parser.parse_args() defined in global scope fails #10

Closed mfitzp closed 7 years ago

mfitzp commented 9 years ago

As described by @CatherineH here https://github.com/wooey/Wooey/issues/44


Okay, I think I've figured it out -

issue 1, the argparser problem that I started with, is caused by having both the argparser and the parser.parse_args() defined in global scope. For example, this script works:

import argparse
import sys

parser = argparse.ArgumentParser(description='testing wooey.')
parser.add_argument('--arg1', type=str, default="bloop", help='argument 1')
parser.add_argument('--arg2', help='argument 1', type=str, default="bloop")
parser.add_argument('--arg3', help='argument 1', type=str, default="bloop")

def main():
    args = parser.parse_args()
    print(vars(args))

if __name__ == "__main__":
    sys.exit(main())

So does this script:

import argparse

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='testing wooey.')
    parser.add_argument('--arg1', type=str, default="bloop", help='argument 1')
    parser.add_argument('--arg2', help='argument 1', type=str, default="bloop") 
    parser.add_argument('--arg3', help='argument 1', type=str, default="bloop")

    args = parser.parse_args()
    print(vars(args))

but this one does not:

import argparse

parser = argparse.ArgumentParser(description='testing wooey.')
parser.add_argument('--arg1', type=str, default="bloop", help='argument 1')
parser.add_argument('--arg2', help='argument 1', type=str, default="bloop")
parser.add_argument('--arg3', help='argument 1', type=str, default="bloop")
args = parser.parse_args()
print(vars(args))

which used to work in a previous version of Wooey.

Chris7 commented 7 years ago

This is no longer a bug. Probably fixed via #16