Skip to content

Create dependency-inversion-after-comp.py #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m1009d
Copy link

@m1009d m1009d commented Jan 16, 2022

Hi Arjan,

thanks a lot for your videos on YouTube, it's super helpful for me to learn more about Python. You are doing a great work to the community, really appreciating.

Here is just my simple idea how to (possibly) use composition instead of inheritance in the dependency-inversion-after.py.
Please if you have some time, could you check this code and comment what would you change (if anything) and if you think it make sense we could even merge it.

Thanks again.

Just my simple idea how to (possibly) use composition instead of inheritance in the dependency-inversion-after.py
Comment on lines +18 to +21
total = 0
for i in range(len(self.prices)):
total += self.quantities[i] * self.prices[i]
return total
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
total = 0
for i in range(len(self.prices)):
total += self.quantities[i] * self.prices[i]
return total
return sum(quantity * price for quantity, price in zip(self.quantities, self.prices))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants