ModularM
Modular3y ago
10 replies
Egod

cmd args parse

I want to use the argparse package in Python, but it's painful to write a mojo code like

from python import (Python, PythonObject)

fn main():
    try:
        let ap = Python.import_module("argparse")
        let parser = ap.ArgumentParser()
        parser.add_argument(...) # this line is painful since key args are not supported yet
        ...
    except e:
        print(e.value)


thus I think it will be more reasonable to implement a simple argparse in mojo....

The question is that is there any existing codes? or would Modular offer official module in the future?
Was this page helpful?