https://github.com/sngjuk/argparse-to-class
Transform argparse into class format for Jupyter Notebook execution
https://github.com/sngjuk/argparse-to-class
argparse argument-parser arguments ipython-notebook jupyter jupyter-notebook
Last synced: 9 days ago
JSON representation
Transform argparse into class format for Jupyter Notebook execution
- Host: GitHub
- URL: https://github.com/sngjuk/argparse-to-class
- Owner: sngjuk
- License: mit
- Created: 2017-09-01T09:30:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-02-17T18:39:32.000Z (about 4 years ago)
- Last Synced: 2025-02-01T10:22:58.068Z (20 days ago)
- Topics: argparse, argument-parser, arguments, ipython-notebook, jupyter, jupyter-notebook
- Language: Python
- Homepage:
- Size: 113 KB
- Stars: 21
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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) :

### ouput (args class) :

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