r/learnpython • • Dec 20 '20

Example of a simple and well made Python project on Github

Hi, I'm wanting to have a look at some examples of really well made but extremely simple python projects in an attempt to better understand basic structure and design. People suggest to me things like Requests or Flask... they may be beautiful but they are way too complex for what I'm after.

Any suggestions that come to mind?

329 Upvotes

53 comments sorted by

42

u/FatherOfTheSevenSeas Dec 20 '20

To clarify, I don't want to make a project, I'm wanting to look at existing projects for reference.

34

u/gimlidorf Dec 20 '20

If i understand correctly do you want to see how project's are laid out on github?

4

u/[deleted] Dec 20 '20

Have you thought about a good book for projects? Id recommend automate the boring stuff.

0

u/[deleted] Dec 20 '20

[deleted]

4

u/[deleted] Dec 20 '20

Absolutely it is why I recommend it. It also has the typical projects you hear about like web scrapping and covers working with files and various other projects. I ended up going the Java/Sql path so I didn't use it too much but I learned some fun stuff with the book.

3

u/benjmnz Dec 20 '20

I have a repo I just created that has a simple text number guessing game with betting, written using Python 3.9 in PyCharm that you can look at here: https://github.com/CardinalRichelieu/GuessingGame ...

Made for beginners by a beginner. Hope this is what you were looking for.

1

u/ballangddang Dec 12 '25

mais c'est complétement nul lol en plus tu as inclus "venv" dans ton dépôt alors qu'il faut toujours l'ignorer. Tu peux pas juste poster un lien d'un de tes projets bidon alors que OP demande des exemples de projets pour apprendre les bonnes pratiques....

1

u/luisgc93 Dec 29 '20

You shouldn't commit the venv or .idea directories

1

u/ArmadilloChubbz20 Jan 12 '21

It is best to add a .gitignore file to the project and ignore the venv and .idea directories. That data is only useful to yourself and your development environment. Someone using Visual Studio Code would not those files in the project when they download it.

2

u/hany_codes Dec 20 '20

Honestly, I would recommend just creating a project and working on it. Then having it here so people can criticize it and you can get better fixing your own stuff. There are plenty of styles out there, there is no like standard in my opinion. If it works then I guess it is fine. Because you are always gonna change it and make it better.

18

u/fritz_0 Dec 20 '20

This is pretty much the project structure I use: https://github.com/bast/somepackage

3

u/FatherOfTheSevenSeas Dec 20 '20

That was cool, thanks.
Question: Why no __main__ ?

4

u/fritz_0 Dec 20 '20

You can add a __main__.py file if you want/need to, it's just to give a general idea of how to structure your module/program so it's pretty barebones.

1

u/[deleted] Dec 20 '20

Why would there be a main.py file? 0_o

6

u/DonkeyTron42 Dec 20 '20

Personally, I've found that once you start getting into intermediate Python there is precious little "useful" information on the Internet to make it across this chasm. There's lots of bits and pieces but not so much that ties it all together. I've been working with JetBrains Adademy and so far this has been very useful to me. It's not free but there is a 2 month trial followed by 1 year of $24.95/mo for a subscription.

r/Hyperskill

https://www.jetbrains.com/academy/

1

u/FatherOfTheSevenSeas Dec 20 '20

Totally. Chasm is a great word for it.

Which strand/course have you taken up on jetbrains?

1

u/DonkeyTron42 Dec 20 '20

I started with the beginner Python track since I'm already pretty fluent in Python just as a baseline. I learned a few things but blew through it pretty quickly. I'm in the the intermediate now I find this approach very helpful. One thing I like is they don't spoon feed you too much since anyone can Google the concepts they're trying to teach. I also like that the community is very strong and there is a discussion for every lesson. If you're stuck, just look at the comments, go to the discord, reddit, etc... and it's not hard to find help for that specific topic. One thing I don't like about r/learnpython and such is that you have to filter through so much chaff to find the kernel of wheat you need. In my experience that's typically the case with anything that's "free".

2

u/FatherOfTheSevenSeas Dec 20 '20

Thanks for this. Think I've just found my xmas break project..

1

u/scienceNotAuthority Dec 20 '20

Jetbrains is heavily advertised and not needed. Avoid

52

u/[deleted] Dec 20 '20

You should checkout the discord.py repository! It's well structured. https://github.com/Rapptz/discord.py

6

u/DoozerMarch Dec 20 '20

No tests though?

17

u/Rapptz rapptz Dec 20 '20

Unfortunately this is due to Discord being a hard platform to do unit testing on. If I were to do testing however I'd just add a tests directory and write all the test_foo.py files there. It wouldn't radically change the project structure.

5

u/ipagera Dec 20 '20

Why is it hard to write unittests for? There's an API call limit or?

10

u/carnivorousdrew Dec 20 '20

api calls should be mocked in unittests

3

u/kaizzuu Dec 20 '20

Happy cake day buddy 🙃🍰

1

u/DUST-LMAO Dec 20 '20

Hapy cake day

1

u/evan_0x Dec 20 '20

Lots of python magic including meta programming in this repo

1

u/luisgc93 Dec 29 '20

It's missing test coverage IMO. The alpha vantage API wrapper has a similar purpose and has tests:

https://github.com/RomelTorres/alpha_vantage

9

u/Retropunch Dec 20 '20

My advice with this is to make a structure and stick with it. Python is flexible enough that most structures work, and if it makes sense to you intuitively then you'll get much better at coding.

If you're going into a career/going professional, most companies will have their own structure which you'll have to follow...and every other company will have a different one.

The most important things are:

  • Modularise everything you can. I tend to do 'themed' modules, some people do basically a module per function.

  • Don't use different folders unless your project is getting really, really big

  • Stick to one casing format (case_it, caseIt, CaseIt etc.)

  • Decide if you're going to have something to denote module only functions (most people use _fuction or _foo to differentiate it)

  • Comment your code like there's going to be a man with a gun to your head in two years time asking you what each block of code means.

6

u/MyPythonDontWantNone Dec 20 '20

You can replace a lot of comments with proper variable names and heavy use of the logging library.

4

u/Retropunch Dec 20 '20

Whilst you're completely correct that those two things are a must, commenting is still vital.

I can't count the amount of times someone has given me uncommented code and gone 'it's very self explanatory' - it never is. Never ever.

What you think is obvious will be completely alien to someone who hasn't spent hours with the code like you have, or they wouldn't call x what you have called it etc.

2

u/Discchord Dec 29 '20

What you think is obvious will be completely alien to someone who hasn't spent hours with the code like you have, or they wouldn't call x what you have called it etc.

This is something every new programmer tries to rush over it seems. Even if you're the only one that will ever look at your source code, you should be commenting.

It will amaze you how many of your early projects are still being used somewhere 5 years down the line. If you ever need to come back and change any of that, you're fucked without comments. You will have no idea what you're even looking at, because in 5 years time your own coding style with change dramatically as you improve. My first two Python apps are still running on a little server doing their thing. Trying to tweak anything in them is a nightmare because it was all Python 2 and my patterns were just all over the place.

1

u/Retropunch Dec 29 '20

Absolutely! I think part of the problem is that new programmers think 'this isn't complex enough to need commenting' and then never realising when it is finally complex enough to need it.

It's better to comment on everything I believe, and write it out in detail if it's a complex function. There's no execution or size cost to writing out a proper paragraph on a difficult function, and you'll never ever remember anything as well as you think.

26

u/flyawayonmyzwifter Dec 20 '20

Python is pretty versatile, and also used by people with different skill sets and industries.

So, give us something to work with. What interests you? What is your perceived application of python?

If I was to suggest a gold standard I’d recommended the flask mega tutorial by Miguel Grinberg. That would be because I’ve become very successful in my day to day job because of implementing flask and API’s.

Michael Kennedy at Talk Python also is the gold standard to developing apps in Python.

For less than $100 USD you could support the best content creators in the Python community.

Both have public git repo’s you could learn from if you don’t want to pay for content.

4

u/[deleted] Dec 20 '20

Sure, I have a bunch of "one file" projects I wrote myself and a bunch of them are production ready by now.

Starting from the simplest:

10

u/nickhepler Dec 20 '20

NewCoder.io had a few good intermediate tutorials with full code, but they were written in Python 2 so the may not be perfect. It does have good examples of a functional program, object-oriented program, and one with a GUI

3

u/chonyyy Dec 20 '20

These are some simple Python ML projects I built. Feel free to check it out!

At the beginning of this year, I'm also a junior dev like you who don't know how to start a project. And I would say that checking out other people's projects really helps a lot!

A little tip I would give is to not care too much about the structure. Just start coding whatever you can think of and you will figure out the structure you are comfortable with.

https://github.com/chonyy/AI-basketball-analysis

https://github.com/chonyy/ML-auto-baseball-pitching-overlay

3

u/scienceNotAuthority Dec 20 '20

I have an idea for you. Do you import anything in your projects? For instance,

import time

You can look up that on GitHub. It will be high quality and useful.

1

u/qtc0 Dec 20 '20

You can look at the Cookiecutter templates

1

u/baetylbailey Dec 20 '20

The best libraries are the ones you use right now and the one ones you'd want to write.

Use your IDE's 'goto definition' to inspect the objects you use. Even better is turning on debugging in third party libraries and stepping through the code.

1

u/YayotinaXbenzos Dec 21 '20

I’d check out some styling guides, here’s a couple pointers https://google.github.io/styleguide/pyguide.html

https://github.com/kengz/python

https://pep8.org

Also I’d suggest checking out big tech companies GitHub repos and look at the contributors repos etc

-1

u/BeginnerProjectBot Dec 20 '20

Hey, I think you are trying to figure out a project to do; Here are some helpful resources:

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github

-3

u/metal_jd Dec 20 '20

!projectbot easy

9

u/BeginnerProjectBot Dec 20 '20

Hey, I think you are trying to figure out a project to do; how about this one?

Project: Quiz App

I think its a nice project for you! Try it out but, dont get discouraged. If you need more guidance, here's a description:

Create a Quiz Application which will prompt the user for an answer to a question. Provide multiple answers for the user to select

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github

-4

u/gimlidorf Dec 20 '20

!projectbot medium

!projectbot easy

1

u/BeginnerProjectBot Dec 20 '20

Hey, I think you are trying to figure out a project to do; how about this one?

Project: Find out, Fibonacci!

I think its a cool project for you! Try it out but, dont get discouraged. If you need more guidance, here's a description:

You input a number and the function created checks whether the number belongs to the Fibonacci sequence or not.

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github

0

u/[deleted] Dec 29 '20

[deleted]

1

u/FatherOfTheSevenSeas Dec 30 '20

Thank you! This is one of the best examples which has been posted here.

0

u/[deleted] Dec 20 '20

[deleted]

6

u/BeginnerProjectBot Dec 20 '20

Hey, I think you are trying to figure out a project to do; how about this one?

Project: Countdown Clock and Timer

I think its a challenging project for you! Try it out but, dont get discouraged. If you need more guidance, here's a description:

Create a UI in which the user can set a timer, and the app notifies you when time is up through an alert

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github

1

u/[deleted] Dec 20 '20

Hey that's what I was thinking to work on (using GoLang)

1

u/elrey_scarbrow Dec 20 '20

I made a GUI pomodoro timer. Does that mean I pass the intermediate level?

0

u/[deleted] Dec 20 '20

[deleted]

2

u/BeginnerProjectBot Dec 20 '20

Hey, I think you are trying to figure out a project to do; how about this one?

Project: Hangman

I think its a cool project for you! Try it out but, dont get discouraged. If you need more guidance, here's a description:

Create a game to play the classic hangman game! Start off simple by selecting a random word (or prompt a user for one), and prompt the user for letters. You can build on it by adding the hangman graphic either in a GUI or the text console

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github

0

u/[deleted] Dec 20 '20

[deleted]

2

u/BeginnerProjectBot Dec 20 '20

Hey, I think you are trying to figure out a project to do; how about this one?

Project: Python Website Blocker

I think its a challenging project for you! Try it out but, dont get discouraged. If you need more guidance, here's a description:

Create a blacklist of websites to block while surfing the web.

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github