Showing posts with label ArgumentParser. Show all posts
Showing posts with label ArgumentParser. Show all posts

1/11/2023

How to call module written with argparse in iPython notebook

 


Add this two line above "argparse.ArgumentParser()" line

ex)

..

##add sys code ##
import sys
sys.argv = ['']

##origin code##
import argparse
parser = argparse.ArgumentParser()
args = parser.parse_args()

..


Thx. πŸ™‡πŸ»‍♂️

www.marearts.com

8/25/2022

use easy attribute class using "argparse", "ArgumentParser"

 see the example code

.

import argparse

#define as default
paser = argparse.ArgumentParser()
args = paser.parse_args("")

#assign values
args.cuda = False
args.device = 'cpu'

#print
print(args)
print(args.cuda)

.


Thank you.

www.marearts.com