Egod
Egod
MModular
Created by Egod on 9/12/2023 in #questions
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)
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?
11 replies