Closed madalinpopa closed 4 years ago
well we're glad to hear that someone is trying to run the code! i guess you figured out the bug?
how are you enjoying the book in general?
Hi @hjwp ,
Thank you for replying. Well, I think it is the second time I read this book. The first time I just got through it very quickly, and I have read it like it was novel. I really like the style of how it was written, and I love that you are constant. I found the same writing manner as in the first book that I read from you, Test-Driven Development with Python.
Now I decided to read it one more time and also to get my hands dirty with those exercises and the code examples you have provided along with this book.
Even they are evident and concise; I have encountered some difficulties in applying and understanding some of them. Like the example, this piece of code for which I have created this issue.
If you could let me know more details about this specific example and where do you catch that IndexError
I will be grateful. :)
well that product.events.pop
is inside a while product.events
block so in theory it can never be empty, and you should never be able to cause an IndexError
have you got a repo somewhere you can share, maybe with a test case that reproduces the error?
i'm glad you've been trying the exercises too! how did you find them?
Yes, you are right. I just double-checked my code, and I found the mistake.
They are great, and if you want to understand them, then definitely, you need to run them. Just reading and glancing through this repo is not enough. I am glad that I did this because now I have connected all the dots, and for sure when I will recommend this book, I will strongly suggest following the code examples along with the book chapters.
Thank you, guys for writing this book, and we are waiting for more to come.
Hi Harry & Bob,
I was not able to make this piece of code work without adding a checking for an empty list:
With this, I am getting the following exception:
IndexError: pop from empty list
Is this working without checking if
product.events
is empty?Reference: https://github.com/cosmicpython/code/blob/e3de63c922c2094d63949949b4cdf776fb5462dc/src/allocation/service_layer/unit_of_work.py#L28