davidslv / checkout.py Goto Github PK
View Code? Open in Web Editor NEWA checkout written in Python
A checkout written in Python
In python it can be problematic to have an object as default argument like a list []
or dict []
as you have in pricing_rules=[]
. Because that part of the code only runs once and so that list will always be the same.
https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L6
I would try to load the list of products in the checkout init dynamically from a CSV file.
https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L12
For the list of products in memory, I suggest using a dictionary instead of a list, so that you can quickly access a product using their code.
https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L12
To calculate the sum of discounts you could use something similar to what you did in the total.
total -= sum(rule.discount(self) for rule in self.pricing_rules)
https://github.com/Davidslv/checkout.py/blob/master/checkout.py#L24
4.1. Also I would only pass the basket
instead of the checkout instance.
In the Bulk Discount, why are you saving storing the t_item
?
https://github.com/Davidslv/checkout.py/blob/master/bulk_discount.py#L12
In the Bogof Discount, was it for a specific product? I thought all items could have this discount.
https://github.com/Davidslv/checkout.py/blob/master/bogof_rule.py#L6
So, no big tips on the code man. Everything looks pythonic ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.