Lets say I have a class that represents some data (in this example just an array of numbers) I will load from a text file, and store it in an Object data.rawData; Now say I want to double the value of each number. What is the best way to do this?
Python has libraries for data analysis. In this specific case you would use something called list comprehension which can double elements in an array like so:
array = [1,2,3,4,5,6,7,8,9,10]
double = [2*x for x in array]
PyCon is a good resource on lectures for data analysis using Python (You can check youtube for prior events):
When you say that it is a piece of code that envelopes existing code, it sounds much like a function inside of a function. Whereas recursion is when a function calls itself, I am supposing a wrapper is the function that calls another function. Or perhaps even, it returns that same function (slightly modified even).
I am thinking of a programming analogy (code that is analogous to real life) that demonstrates wrappers and decorators.
They say decorators are syntactic sugar (easier on the eyes?) for wrappers. So a decorator is a "better way" to create a wrapper? Or is it a better way to apply a wrapper?
Is my idea still correct? Is it a function that calls or returns another function? From my research, it seems there is a broader definition.