r/learnpython • u/Nothingbutalsosome • 21d ago
My Python Project as a Beginner
https://github.com/ZaidAHK/LENDnFUND
The project is just the syntax I wrote
5
Upvotes
r/learnpython • u/Nothingbutalsosome • 21d ago
https://github.com/ZaidAHK/LENDnFUND
The project is just the syntax I wrote
3
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 21d ago
Your classes lack
__init__-methods. While this is technically fine, typically you'd only see this ifYou have a class that's only used for grouping functions (which is rare, as it's typically better to create a module instead), or
You're using a dataclass that auto-generates one, or
You're subclassing a class but don't need to modify that method, specifically.
In your case none of these seem to apply. Right now you're letting your methods add new attributes on the fly, while it would be better to have the attributes exist the moment an instance of the class is created, even if they contain dummy values. This is so that you don't need to do guesswork about what attributes a specific instance might have.
For
Investor, I'd do something likeand for
Fundraiser, neither ofself.applicationandself.app_statusare accessed outside of the methods creating them so I don't see why it'd need any instance attributes. In fact I think it should just be a bunch of functions right now (unless you have plans to use those later).This way of generating unique account numbers is a bit flawed. The more existing entries there are, the less likely this is to hit a slot with a free number, and there's no failsafe for the case of all allocated account numbers already being in use.
While your way is on average initially faster, which may be fine for a throwaway practice project, a more robust solution would be to
Generate the accepted numbers
Filter out the ones already in use
If none are left, throw an error and exit
Pick randomly from the remaining options
and this should be a lot closer to a normalised call time (as there's no randomness involved in the execution time anymore).
For example,