Skip to content

Transform argparse into class format for Jupyter Notebook execution

License

Notifications You must be signed in to change notification settings

sngjuk/argparse-to-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Argparse2class for Jupyter execution.

Argparse transformation for Jupyter Notebook execution. (for quick testing in .ipynb)
Copy & paste class-formatted arguments to replace argparse.

Notice! It's better to use args = parser.parse_args(args=[]) syntax - https://stackoverflow.com/a/47587545/3618853

quick web transformation :

http://35.192.144.192:8000/arg2cls.html

usage :

python3 arg2cls.py [target.py] [target2.py(optional)] ...

make argument parser into-

parser = argparse.ArgumentParser(description='PyTorch PennTreeBank RNN/LSTM Language Model')
parser.add_argument('--data', type=str, default='./data/penn',
                    help='location of the data corpus')
parser.add_argument('--model', type=str, default='LSTM',
                    help='type of recurrent net (RNN_TANH, RNN_RELU, LSTM, GRU)')
parser.add_argument('--emsize', type=int, default=200,
                    help='size of word embeddings')
parser.add_argument('--nhid', type=int, default=200,
                    help='number of hidden units per layer')

class format

class args:
    data = './data/penn'
    model = 'LSTM'
    emsize = 200
    nhid = 200

input (argparse lines) :

alt text

ouput (args class) :

alt text

transformed usage :

If there's no default value for argument, It will have warning value. (###manual_setting_required###)

alt text

About

Transform argparse into class format for Jupyter Notebook execution

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published