Skip to main content

Modify the functions dynamically

Project description

[pypi][pypi]

#How To Install

pip install WIND-liang233

#Wind Is Not a Decorator A dynamic decorator? Maybe...

How To Use

Just as the example.py

Features

1.Modify the function dynamically!

JUST LIKE THE CODE IN EXAMPLE.py

import Wind


# DEFINE
class WRAPPER(Wind.Wind):
    def __init__(self, target_func, global_handlers, *args, **kwargs):
        ...

    def run(self, args_dict, *args, **kwargs):
        self.target_func(*args, **kwargs)
        print(args_dict["string"])
        print("Wind is not a decorator!")


class WRAPPER2(Wind.Wind):
    def __init__(self, target_func, global_handlers, *args, **kwargs):
        ...

    def run(self, args_dict, *args, **kwargs):
        print("Begin!")
        self.target_func(*args, **kwargs)
        print("End")


# TEST FUNCTION
def liang(string, string2):
    print(string + ", " + string2 + "!")


# EXECUTION

# The First Wrap
a = WRAPPER(liang, globals())
a.wrap(vars())
liang("HELLO", "MR.liang")

# RESET THE FUNCTION
a.reset(vars())
print()

# The Second Wrap
b = WRAPPER2(liang, globals())
b.wrap(vars())
liang("HELLO", "MR.liang")
b.reset(vars())

And We Get These Outputs:

HELLO, MR.liang!
HELLO
Wind is not a decorator!

Begin!
HELLO, MR.liang!
End

2.Maybe you can ... get the arguments of the function:


...

class GET_ARGS(Wind.Wind):
    def __init__(self, target_func, global_handlers, *args, **kwargs):
       ...

    def run(self, args_dict, *args, **kwargs):
        print(args_dict)
        
c = GET_ARGS(liang, globals())
c.wrap(vars())
liang("HELLO", "MR.liang")

And We can get these:

{'string': 'HELLO', 'string2': 'MR.liang', 'KWARGS': {}}

Really Powerful, isn't it?

SOMETHING ELSE

Bilibili: @liang_awa

DONATE? : HERE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Wind_is_not_decorator-0.20.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Wind_is_not_decorator-0.20-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file Wind_is_not_decorator-0.20.tar.gz.

File metadata

  • Download URL: Wind_is_not_decorator-0.20.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for Wind_is_not_decorator-0.20.tar.gz
Algorithm Hash digest
SHA256 24dca95674bf7a06ece711539a0d17e67ab1b2cda8d99c524a556376918220d1
MD5 921770d721fde3a60feaa9ae6f36cfe0
BLAKE2b-256 88877fc73f294670d3d9a329f077a04d76196d1b8c84b8ee0de7bf578731da8c

See more details on using hashes here.

File details

Details for the file Wind_is_not_decorator-0.20-py3-none-any.whl.

File metadata

File hashes

Hashes for Wind_is_not_decorator-0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 9c1b6df26c91549125b76c442c0b9f0a2c2ae8138d2b25a7a3b600ff7e432061
MD5 448a42ec8641ac331758768168cd23ef
BLAKE2b-256 53899e0df671e434cba6dbc48b8da62ff26e436f406f112d519f51737dd011af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page