Skip to main content
https://img.shields.io/pypi/v/wisepy2.svg

Wisepy2

Since we found that the capabilities/features doesn’t attract people into using wisepy, thus we go to an extreme, making the simplest command line tool for Python, but also capable of covering the regular use cases.

Two examples are given in the root directory of this project.

from wisepy2 import *


def add(left: int, right: int):
    """
    add up two numbers.
    """
    print(left + right)
    return 0

if __name__ == '__main__':
    wise(add)()
https://raw.githubusercontent.com/Xython/wisepy2/master/example-add2.png
@wise
class Cmd:
    class Int:
        @staticmethod
        def add(a: int, b: int):
            print(a + b)

    class Str:
        @staticmethod
        def concat(a: str, b: str):
            print(a + b)

    @staticmethod
    def repeat(a: str, b: int):
        print(a * b)

if __name__ == '__main__':
    wise(add)()

shell> python xxx.py Int add 1 2 # 3
shell> python xxx.py Str concat 1 2 # 12
shell> python xxx.py repeat 1 2 # 11

Usage

Wisepy2 converts a function into a command, where following components of python functions correspond to the command components. Here’re the mapping rules:

  • variadic args: a positional argument that accepts variable number of arguments, like nargs="*" in argparse.

  • annotations: an annotation will be transformed to the help doc of an argument. If it’s a type, the argument is automatically converted to the type you expect.

  • default argument: default value will be equivalent to specifying default in argparse.

  • keyword argument: keyword only or postional_or_keyword arguments with default values can be passed by --arg value.

  • arguments that’re annotated bool and have True or False default arguments: these arguments can changed as the opposite of its default value by giving --arg.

Metadata

Release files for wisepy2 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for wisepy2 1.4.1
File Interpreter ABI Platform
wisepy2-1.4.1-py3-none-any.whl Python 3 none any Details

Release files / wisepy2-1.4.1-py3-none-any.whl

Download URL wisepy2-1.4.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
522f68f1a2be0657548e6431fcb6e20a819fad1054d010a7dcc0b1a7e7adc7d3
BLAKE2b-256 checksum
How to use checksums
3e621ab672ce622c41452fb2a6a3d6e71d9050809426c2f82aa6786f90e6a535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.4.1 This release

1 release file

1.3

1 release file

1.2.1

1 release file

1.2

1 release file

1.1.1

1 release file

1.0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page