Closed sanoke closed 7 years ago
Added in pull request (#10)
@brennan-ae I'm assuming that b/c this issue is closed, we're able to run
isinstance( lazy_add(1,2), LazyOperation ) == True
...? I haven't tested this myself yet, although I will (it's further down on my To Do list).
Task (from Project Spec 3) Create a new file called
lazy.py
.Inside, create a new class called
LazyOperation
, which will be our thunk. The constructor should take one required argument function and then arbitrary positional and keyword arguments (this is the*args
and**kwargs
syntax, if you remember). The constructor doesn't need to do anything but store them internally for now.This follows what we did in the lecture.
Write a
@lazy
decorator now.Add in a
lazy_add()
and alazy_mul()
and use these to write tests forlazy.py
.If you've done it correctly, you should be able to run something like this: