The 1 Page Python Book by Barani Kumar

The 1 Page Python Book by Barani Kumar

Author:Barani Kumar
Language: eng
Format: epub, pdf
Tags: programming, scripting, python ui, python coding, python ebook, python guide, learn python programming
Published: 2021-08-01T00:00:00+00:00


add = modified_add(add) #4)

add(5,6) #5)

Lets understand the code above to understand decorators.

1) There is a simple add function defined. IT can accept 2 numbers, add them and produce a output number. Eg: 5 + 6 = 11

2) But I want to modify this behavior by changing the inputs, every input is incremented by 1.5 and then added. For this a new function is created.

The input to this modified_add is the original function.

Any arguments passed to the original function can be received as arbitrary arguments inside a nested function (wraps) It can be given any user defined name.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.