Skip to main content

This defines a decorator that causes the 'result' variable to be returned when there is no explicit return

Project description

PyPI version Python versions Black codestyle

return-result

This defines a decorator that causes the variable result to be automatically returned from a function when there is no return statement.

This works by getting the source code of the decorated function, so this won't work in the CPython REPL. It does work in IPython however.

Inspired by the Nim feature that does the same thing.

Example

>>> from return_result import return_result
>>> @return_result
... def test():
...     result = "Works!"
>>> test()
'Works!'

Requirements

Python 3.6+

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

return-result-1.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

return_result-1.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file return-result-1.1.0.tar.gz.

File metadata

  • Download URL: return-result-1.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.7.12-arch1-1

File hashes

Hashes for return-result-1.1.0.tar.gz
Algorithm Hash digest
SHA256 af836aa1aee89e6500932a8afaa139d791f940468a6ed8fb0f56b59e0fc80811
MD5 e5190115cfcd17b90541be92ff4c0bc6
BLAKE2b-256 f125e091ccb8a2849cbb1e90e05d886361071094b08087d2fd2615b20f743726

See more details on using hashes here.

File details

Details for the file return_result-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: return_result-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.8.5 Linux/5.7.12-arch1-1

File hashes

Hashes for return_result-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a6721d2a27c3cbdc099a18d61a7fbb30e870e97a6cdd2890e0e8b696347994
MD5 aad3c675b18872970ecc38b8ddd12274
BLAKE2b-256 8d4eadc5991852d96f350c4335f52774f1b4c17fb9af8113b4451f99839d8bb3

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