Skip to main content

decorator: make keywords arguments of bool values from function attributes

Project description

script:

from kwattr import kwattr

@kwattr.wait.chdir.min.max.hide
def run(*args, **kwargs):
    return args, kwargs

@kwattr.all.dirs
def scan(arg, idir=False, ifile=True, all=False, dirs=False):
    return arg, idir, ifile, all, dirs

print run.wait('sample.exe')
print run('sample.exe')
print run.wait.chdir('sample.exe')

out:

(('sample.exe',), {'max': False, 'chdir': False, 'hide': False, 'min': False, 'wait': True})
(('sample.exe',), {'max': False, 'chdir': False, 'hide': False, 'wait': False, 'min': False})
(('sample.exe',), {'max': False, 'chdir': True, 'hide': False, 'min': False, 'wait': True})

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

kwattr-2.0.zip (2.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page