Skip to main content

Decorator for your functions, for easy tune of boolean arguments

Project description

# Magwitch
The magical switch switcher !

```python
import magwitch

@magwitch.on
def save_figure(in_png:bool=False, legend:bool=True):
... # an implementation we do not care about for the example
return in_png


# Now, you can set the value of the boolean arguments by giving their name:
assert save_figure.in_png() is True

# Or not:
assert save_figure.not_in_png() is False

# Also, you can do it multiple times:
save_figure.not_in_png.no_legend()

# The last set is autoritative
assert f.not_in_png.in_png() is True

# And there is many other options if you want to !
@magwitch.on_with(use_defaults=True, enable='do_', disable=('nope_', 'never_'):
def f(a:bool=False): return a

# effect of use_defaults
assert f.do_a() is False
```

See the [tests](test/) for complete API, and the docstring of `Magwitch.build`
for a description of all available parameters.


Install with

pip install magwitch

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

magwitch-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file magwitch-0.1.0.tar.gz.

File metadata

  • Download URL: magwitch-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for magwitch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c8760f07857ab1e674b770905f38f9c572ac40a2180535e68345b6728bea134
MD5 c61757d8b9512fdcbefb39e5a578a5f7
BLAKE2b-256 1812d5c09ece8438e9a7525d83d86d222ba6142cb9e93a878e3980413345f145

See more details on using hashes here.

Supported by

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