argparse coding issue

Posted by Carl Skonieczny on Stack Overflow See other posts from Stack Overflow or by Carl Skonieczny
Published on 2012-04-02T23:07:04Z Indexed on 2012/04/02 23:30 UTC
Read the original article Hit count: 201

Filed under:
|

write a script that takes two optional boolean arguments,"--verbose‚" and ‚"--live", and two required string arguments, "base"and "pattern". Please set up the command line processing using argparse.

This is the code I have so far for the question, I know I am getting close but something is not quite right. Any help is much appreciated.Thanks for all the quick useful feedback.

def main():
    import argparse
    parser = argparse.ArgumentParser(description='')
    parser.add_argument('base', type=str)
    parser.add_arguemnt('--verbose', action='store_true')
    parser.add_argument('pattern', type=str)
    parser.add_arguemnt('--live', action='store_true')

    args = parser.parse_args()

    print(args.base(args.pattern))

© Stack Overflow or respective owner

Related posts about python

Related posts about homework