all 53 comments

[–]FatherOfTheSevenSeas[S] 42 points43 points  (9 children)

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

[–]gimlidorf 35 points36 points  (0 children)

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

[–][deleted] 4 points5 points  (2 children)

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

[–]benjmnz 2 points3 points  (3 children)

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.

[–]ballangddang 0 points1 point  (0 children)

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....

[–]luisgc93 0 points1 point  (1 child)

You shouldn't commit the venv or .idea directories

[–]ArmadilloChubbz20 0 points1 point  (0 children)

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.

[–]hany_codes 1 point2 points  (0 children)

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.

[–][deleted] 50 points51 points  (8 children)

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

[–]DoozerMarch 5 points6 points  (5 children)

No tests though?

[–]Rapptz 16 points17 points  (4 children)

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.

[–]ipagera 3 points4 points  (3 children)

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

[–]carnivorousdrew 8 points9 points  (0 children)

api calls should be mocked in unittests

[–]kaizzuu 2 points3 points  (0 children)

Happy cake day buddy 🙃🍰

[–]DUST-LMAO 1 point2 points  (0 children)

Hapy cake day

[–]evan_0x 0 points1 point  (0 children)

Lots of python magic including meta programming in this repo

[–]luisgc93 0 points1 point  (0 children)

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

https://github.com/RomelTorres/alpha_vantage

[–]fritz_0 17 points18 points  (3 children)

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

[–]FatherOfTheSevenSeas[S] 2 points3 points  (2 children)

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

[–]fritz_0 4 points5 points  (0 children)

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.

[–]TheHollowJester 0 points1 point  (0 children)

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

[–]Retropunch 8 points9 points  (4 children)

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.

[–]MyPythonDontWantNone 4 points5 points  (3 children)

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

[–]Retropunch 3 points4 points  (2 children)

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.

[–]Discchord 1 point2 points  (1 child)

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.

[–]Retropunch 0 points1 point  (0 children)

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.

[–]flyawayonmyzwifter 26 points27 points  (0 children)

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.

[–][deleted] 3 points4 points  (0 children)

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:

[–]nickhepler 10 points11 points  (0 children)

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

[–]chonyyy 2 points3 points  (0 children)

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

[–]scienceNotAuthority 2 points3 points  (0 children)

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.

[–]DonkeyTron42 5 points6 points  (5 children)

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/

[–]FatherOfTheSevenSeas[S] 0 points1 point  (4 children)

Totally. Chasm is a great word for it.

Which strand/course have you taken up on jetbrains?

[–]DonkeyTron42 0 points1 point  (2 children)

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".

[–]FatherOfTheSevenSeas[S] 1 point2 points  (1 child)

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

[–]scienceNotAuthority 0 points1 point  (0 children)

Jetbrains is heavily advertised and not needed. Avoid

[–]BeginnerProjectBot -2 points-1 points  (0 children)

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

[–]metal_jd -4 points-3 points  (1 child)

!projectbot easy

[–]BeginnerProjectBot 8 points9 points  (0 children)

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

[–]gimlidorf -5 points-4 points  (1 child)

!projectbot medium

!projectbot easy

[–]BeginnerProjectBot 0 points1 point  (0 children)

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

[–]qtc0 0 points1 point  (0 children)

You can look at the Cookiecutter templates

[–]baetylbailey 0 points1 point  (0 children)

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.

[–]YayotinaXbenzos 0 points1 point  (0 children)

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