ipython-args 1.0.3

Creator: bradpython12

Last updated:

Add to Cart

Description:

ipythonargs 1.0.3

Python Argument Parser for Notebooks and Scripts
Introduction
This Python module provides a versatile argument parsing solution that works seamlessly both in Jupyter notebooks (or similar environments) and standard Python scripts. It allows the same code to accept arguments in two different contexts, making it easier to write code that is flexible and easy to test.
The document is helped by ChatGPT 4.0
Features

Dual Compatibility : Works with Jupyter notebooks and standard Python scripts.
Easy Integration : Simple to integrate into existing Python projects.
Dynamic Argument Parsing : Automatically switches between easydict and argparse depending on the execution environment.

Requirements

easydict
argparse

Installation
Ensure that you have easydict installed. You can install it using pip:
pip install easydict

Usage
Defining Arguments
First, define your arguments in a dictionary format. For example:
args_dict = {
"arg1": value1,
"arg2": value2,
// Add more arguments as needed
}

Parsing Arguments
Then, simply call the ipython_args function with your arguments dictionary:
args = ipython_args(args_dict)

In a Jupyter notebook environment, args will be an EasyDict object, allowing you to access arguments using dot notation (args.arg1). In a standard script, args will be the usual argparse.Namespace object.
Checking Environment
The is_notebook function can be used independently to check if the code is running in a Jupyter notebook environment.
Example
Here's a simple example demonstrating how to use this module:
from ipython_args import ipython_args

# Define your arguments here
args_dict = {
"epoch": 10,
"learning_rate": 0.001
}

# Parse arguments
args = ipython_args(args_dict)

# Accessing arguments
print(args.epoch)
print(args.learning_rate)

You can use is_notebook function to check the environment is notebook or not
from ipython_args import is_notebook

# Check whether the current environment is notebook shell or not
current_env_notebook = is_notebook())

Contributing & Acknowledgements
Thanks for professor Dr. Lee, Soo-Hong who encourage me to upload the project.
This projects are side-project of the National Research Foundation of Korea, ‘Development of a 2-axis ankle exoskeleton robot to identify intentions using deep learning-based EMG images’ (No.2021R1I1A205215811)
License
This project is open-source and available under the MIT License.
Copyright (c) 2018 The Python Packaging Authority
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.