deallocate and fix issues#114
Open
uguryiilmz wants to merge 3 commits intocosmicpython:chapter_04_service_layer_exercisefrom
Open
deallocate and fix issues#114uguryiilmz wants to merge 3 commits intocosmicpython:chapter_04_service_layer_exercisefrom
uguryiilmz wants to merge 3 commits intocosmicpython:chapter_04_service_layer_exercisefrom
Conversation
hjwp
reviewed
Apr 16, 2026
Comment on lines
+23
to
+26
| for batch in self._batches: | ||
| for line in batch._allocations: | ||
| if line.orderid == order_id and line.sku == sku: | ||
| return line |
Contributor
There was a problem hiding this comment.
can't resist suggesting this formulation with next() and a nested list comp. lol
return next(
(l for b in self._batches for l in b._allocations if l.orderid == order_id and l.sku == sku),
None,
)
Contributor
|
Hey, looks good! great job. hope you found the exercise interesting? i think you may be right about the sku... |
Author
|
@hjwp Thanks, Harry. I found the book extremely helpful. This is my second time reading it, and I decided to buy a copy because I'll always carry this around. Especially in the age of AI, architecture and maintenance will be more crucial than ever. Grateful for all the hard-earned experience and wisdom that you shared in the book. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I couldn't find the solution to the exercise for deallocation, so I wanted to share my own. Couple realization I had: