Python HOW TO structure a Beginner OR Advanced Projects ?

  Рет қаралды 125,901

JimShapedCoding

JimShapedCoding

Күн бұрын

Project-based tutorials to become a BETTER Python developer:
- Python Sports Website - • Flask - Live updated ...
- Python Online Bot: - • Selenium FULL COURSE -...
- Python Marketing Website - • Flask Tutorials - Pyth...
#Python #PythonProjects #PythonBeginners #PythonProjectsForBeginners
In this video, you will understand where you should locate your code snippets and why. We will do this by developing a minimal project in two different structures.
☕ Buy me a coffee: www.buymeacoffee.com/jimsc
Connect with me with:
- Instagram: / jimshapedcoding
- E-mail: jimshapedcoding@gmail.com
- Twitter : / jimshapedcoding
- Discord : / discord
👍 Subscribe for more Python tutorials like this:
/ @jimshapedcoding
🔥 Comment below on other topics you want to see tutorials next on my Channel.
-----------------------------------------------
My website:
🔥 www.jimshapedcoding.com
🎥 My KZbin Gear 🎥
Camera (Canon EOS 250D) : amzn.to/314euVC
Microphone (Rode NT-Mini) : amzn.to/3bDqEer
Headphones (JBL LIVE 500BT) : amzn.to/3e73MDS
Tripod (Neewer Portable Tripod) : amzn.to/2OXleC6
Desklight(AUKEY Cordless Lamp): amzn.to/2QaYT4A
Keyboard ( Razer Blackwidow Green Switch ) : amzn.to/3bExDnu
Mouse ( Razer LanceHead ) : amzn.to/3if0JuV
Lights ( Neewer 2-Pack Dimmable ): amzn.to/3oFN1DP
Links I recommend about structuring a project:
docs.python-guide.org/writing...
realpython.com/python-applica...
stackoverflow.com/questions/1...
Link to GitHub of the structures:
github.com/jimdevops19/projec...
Timeline for the video:
00:00 - 15:59 - Structure example for small projects
16:00 - 37:50 - Structure example for larger projects / Packaging with __init__.py

Пікірлер: 129
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Very important point before you watch the whole video, there are millions of ways to structure a project, and the examples I am showing are not the absolute standards of how a project should look like. But the two examples I show are great examples to get going! Enjoy watching
@toolate6971
@toolate6971 3 жыл бұрын
This video is more about writing a script that deals with Prime numbers and far less about program structure.
@Zappabain
@Zappabain 2 жыл бұрын
@@toolate6971 it has been greatly informative to me, after hours of reading official docs etc and not having a clear idea of it. For beginners seeing that code grow and be refactor is very useful to. But I agree I wouldn’t have explained the prime number functions at all.
@ebitdaddyca3676
@ebitdaddyca3676 Жыл бұрын
This is BY FAR one of the best videos out there. My project was getting bigger and bigger and I was getting lost with no knowledge in this field and how to organize an app/project. Thank you SO much my friend!
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Glad it helped you! Appreciate this comment
@malgindesilva2758
@malgindesilva2758 2 жыл бұрын
Very well explained the interconnection. A gem for a beginner/intermediate level Pythonist. Thanks for your time and effort.
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
You're very welcome, Malgin! :)
@fabianstargalla
@fabianstargalla Жыл бұрын
Thank you very much for your video ❤ For me as a beginner it was extremely useful as I had already learnt most of what native Python has to offer but I was never sure what the correct or rather said better way to structure a project would be 🤓
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Thanks a lot for the comment! Glad it helped you
@maxrodriguez643
@maxrodriguez643 2 жыл бұрын
This video just made my brain click to how projects are organized in OOP I always wondered about this specific thing, thank you
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Wonderful Max.
@nothingiseverperfect
@nothingiseverperfect 2 жыл бұрын
Sir, this was INCREDIBLY USEFUL. This deserves more views. THANK YOU SO MUCH
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Wonderful to read such a comment. Hope you will enjoy other videos here as well!
@frankhuang5095
@frankhuang5095 3 жыл бұрын
Such a wonderfully made tutorial! Thanks!
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Thanks! feel free to share it with more people :)
@svenman2139
@svenman2139 2 жыл бұрын
Awesome video, exactly what I was looking for. Thank you :)
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
You're welcome!
@jaypdevaney
@jaypdevaney 3 жыл бұрын
This is an excellent video. Very well explained. Thank you!
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Hey Jay! You're very welcome, please feel free to share it with more people :)
@dennis2599
@dennis2599 3 жыл бұрын
This vide covered the infomation I needed. Thanks :). Ah yeah and btw, what plugin do you use for the code highlightening?
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Glad it helped! It's in pycharm schemes called monokai
@senthilkumarpalanisamy365
@senthilkumarpalanisamy365 3 жыл бұрын
Excellent clear cut explanation, thanks for doing this 👍
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Sure you welcome! Feel free to share it with more people :)
@kevorkkeuchkerian1648
@kevorkkeuchkerian1648 5 ай бұрын
Thank you so much for the video. I was really stuck as to how to structure a project and it was great help!!
@jimshapedcoding
@jimshapedcoding 5 ай бұрын
Glad it was helpful thanks!
@NagasakiNightmare
@NagasakiNightmare 10 ай бұрын
Thank you for this. I really needed this.
@Sycord
@Sycord 2 жыл бұрын
This was an amazing explanation, I just would avoid * for imports.
@raulmorenobello7202
@raulmorenobello7202 2 жыл бұрын
That should have been pointed to newbies like ne, yes. In fact I’ve read the best practice may be to Import module as m And use m.function for every function, class, variable etc the code uses, so it’s always clear to which module it belongs to.
@VectorRoblox
@VectorRoblox Жыл бұрын
Very nice! This is what I was looking for. Thanks
@47_wan
@47_wan Жыл бұрын
It's a great video of introducing Python project structure. : ) But ... I have to point a small mistake, that is "for n in range(start, finish)" where the number denoted by the variable 'finish' won't be checked.
@EdwardVarner
@EdwardVarner Жыл бұрын
Well this was exactly what I needed in my life!
@Kennethlumor
@Kennethlumor Жыл бұрын
Sir please the way you create your packages i also did so but if i import from package a whiles i'm in b i get ModuleNotFoundError: No module named. please i'm using vs code
@nikhil182
@nikhil182 2 жыл бұрын
Thank you Jim🍻 Project structure for advanced project was really useful💯
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Amazing, please share with people that it might be useful for them! :)
@ZinzinsIA
@ZinzinsIA 2 жыл бұрын
Great explanation thank you very much. Just a little question. Which terminal or console do you use ? when I type tree in PyCharm terminal, it only sees the .idea directory and not the files inside my directory. I'd like to have the same printing as you but I don't know how to do. Thank you !
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Hey Geoffrey, no problem. Please share with other people if possible :) You can watch my short video, it will explain how to use the Monokai theme of Pycharm, here is the link kzbin.infoYlK3oLTp53E
@lotansuid9604
@lotansuid9604 3 жыл бұрын
grate video! thats what i look for
@SkegAudio
@SkegAudio 2 жыл бұрын
Hey man, great video! Btw how did you set up your terminal to look like that? It looks awesome!
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Hey Ruben, yep looks cool :) You can download MobaXterm which is an advanced utility to manage local terminal and remote connections to other servers. Very helpful
@science9181
@science9181 2 жыл бұрын
Very well explained with perfect example. Thank you very much! I was wondering - what happens if you change the folder name of the package - then you would have to change every "import" command, right? Isn't there another way?
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Yes, exactly. But if you do this with Pycharm it will automatically suggest you to edit all the "imports"
@BirdmanPRRT
@BirdmanPRRT Ай бұрын
Great video, thanks for sharing!
@jimshapedcoding
@jimshapedcoding Ай бұрын
NP, glad you enjoyed!
@arnavmukherjee5395
@arnavmukherjee5395 Жыл бұрын
Very nicely explained. Many Thanks :)
@salarghaffarian9745
@salarghaffarian9745 Жыл бұрын
Thanks for this great instructive Video!
@bahdev1324
@bahdev1324 3 жыл бұрын
Great info....Jim
@cprn.
@cprn. 3 жыл бұрын
Beginner question. Taking simple project up a notch I'm trying to separate strategies from creatures and I'm lost. Imagine files structure like `/mygame/strategies/voice/{abstract_voice,meow,quack,talk}.py` alongside of `/mygame/creatures/{abstract_creature,cat,duck,human}.py`. I want to type hint `AbstractVoice` in a `@voice_strategy.setter` of `AbstractCreature` but how do I introduce this composition in a sensible manner? How do I make the duck quack, so to speak? If I add `from mygame.strategies.voice import AbstractVoice` in `creatures/abstract_creature.py` I can't re-use creatures + strategies in a package with a different name because this is literally a named package import. But if I replace this with a relative import I get "attempted relative import beyond top level package" when e.g. trying to test just the sub-package. I tried that with and without `__init__.py` files because you don't need them since python3.3. Python is unintuitive mess whenever I try to do anything slightly more complicated than following tutorials.
@vx319
@vx319 2 жыл бұрын
Ask stack overflow that’s too much for a KZbin comment
@cprn.
@cprn. 2 жыл бұрын
@@vx319 Nah, it's an old comment - it can be hacked together badly with `__init__.py` files but my question is how do do it without them and the answer for that is: "can't be done in python because it's fucked up and authoritative".
@vx319
@vx319 2 жыл бұрын
@@cprn. couldn’t you just do an import as and then make it a slightly different name or am I misunderstanding
@Jadushnew
@Jadushnew 8 ай бұрын
What Theme are you using in PyCharm?
@revolution77N
@revolution77N Жыл бұрын
Thanks man! very helpful. I like the accent too :)
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Haha thanks a lot hope you'll enjoy more videos in my channel!
@xavierbourguignon37220
@xavierbourguignon37220 6 ай бұрын
A constant isn’t a variable. A constant is constant, it doesn’t change. A variable as its name indicates can change, it is variable.
@fabiomagrotti2596
@fabiomagrotti2596 2 жыл бұрын
this is not the case but what if Email package needs anything from the Prime package and viceversa? can you just import email.whatever in prime.py and prime.whatever in email.py?
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Hey there Fabio. Not exactly the case because you will face circular import
@Daviddeppe
@Daviddeppe 6 ай бұрын
Excellent explanation! Enjoy the well-earned sub! :)
@heinrichdj
@heinrichdj 3 жыл бұрын
Great video,thanks. What theme are you using in Pycharm?
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Thanks! It's called Monokai should be built-in in Pycharm Community version
@vinayak254
@vinayak254 4 ай бұрын
Thank you jim. It is a great video
@jimshapedcoding
@jimshapedcoding 4 ай бұрын
You welcome!
@TheRastaDan
@TheRastaDan 2 жыл бұрын
Great, this is really something other Python tutorials tend to ignore. Coming from Java, with its strict structure, I was pretty lost, when my python files cracked the 500 lines of code. This will help me alot cleaning up the mess of spaghetti code in my recent project.
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Glad it helped you, thanks a lot for the kind words
@lucaslannes4004
@lucaslannes4004 Жыл бұрын
Dude! Awesome! Ty so much.
@iaroslavdavydiak6439
@iaroslavdavydiak6439 8 ай бұрын
Awesome explanation! 🔥🔥🔥
@blanky_nap
@blanky_nap Жыл бұрын
Great explanation! One question: if i import a class from a module which is in the same folder as the target module (like constants and helpers) why should I still refer to a folder (package) like prime.helpers and can't use helpers directly?
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Hey Dmytro, good question and thanks for following the entire video! That's a possibility, but just improves the readability if in the future you'll import more "helpers" from other packages, so the fact you specify the parent module makes it more understandable what you import
@blanky_nap
@blanky_nap Жыл бұрын
@@jimshapedcoding got it. Thanks!
@MrNess2911
@MrNess2911 Жыл бұрын
Really helpful! Subscribed!
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Thanks for the sub! Hope you'll find more useful content on my channel!
@verbranntenetzhaut
@verbranntenetzhaut 2 жыл бұрын
this video was so good thank you very much!!
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
You're so welcome!
@sigmarepublic7144
@sigmarepublic7144 Жыл бұрын
Dude I’m all in a messy af project! I need to start fresh! How to do that?
@gustavoramirez7889
@gustavoramirez7889 3 жыл бұрын
Awesome! Love to see this coming out as video after asking for it :) Let's give a LIKE first, now lets learn something!
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Love to hear it :)
@inteligenciaartificiuau
@inteligenciaartificiuau 5 ай бұрын
Nice! Thanks!
@Rieske1969
@Rieske1969 3 жыл бұрын
Thank you for the explanation. import or from ... import was quite confusing
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Glad it helped
@LuckyHaboo
@LuckyHaboo 2 жыл бұрын
if there is a data base "SQLite" then where should we put it? Main_dir or sub_dir
@raulmorenobello7202
@raulmorenobello7202 2 жыл бұрын
I’d say in it’s own subdir, at least if it has more than one file (and it probably should have at least a constants.py file, for example for the connection strings for the database so they are not hardcoded lost between the code of the module.
@lucibright9331
@lucibright9331 2 жыл бұрын
1 isn't prime so ur code has a bug ;) Thanks for the tutorial btw, you brighted my day when you said that there isn't a clear standard, bcs that gives me freedom to come up with my own preference. The early suggestions are perfect for getting started, I'll edit when I get to the advanced projects' ones lol. Edit: quite useful, just still didn't found what im looking for, imports are so messy
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Yep should've eliminate the 1 before getting in to the logic of it. Advanced could look a bit too much lines of imports, but it's still worth the mess of import lines as long as you know that those classes (or the helping functions) could reach to hundreds of lines of code.
@raulmorenobello7202
@raulmorenobello7202 2 жыл бұрын
I think you may be interested in the __all__ word for __init__.py files: " if the __init__.py file in the package directory contains a list named __all__, it is taken to be a list of modules that should be imported when the statement from import * is encountered." It also works for modules. BTW, I had sent an answer with a link to best practices for module usage and it has been deleted :(
@CleidsonMachadoDeveloper
@CleidsonMachadoDeveloper 3 жыл бұрын
Thanks a lot!
@MrChatmoon
@MrChatmoon Жыл бұрын
Excellent
@patrykkuniczak2516
@patrykkuniczak2516 3 жыл бұрын
How plugin for coloring a words you using?
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
There are a lot of plugins in mobaXterm that you can use. Generally if you use linux I recommend it. If you own a windows 10 machine that Windows Terminal is what you need (will publish a video for the best setups on that tool soon)
@patrykkuniczak2516
@patrykkuniczak2516 3 жыл бұрын
@@jimshapedcoding Yeah, i using a Win 10, i would like to learn linux in the near future
@lunastela4387
@lunastela4387 2 жыл бұрын
verry informative , that helped me alot : )
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Glad to hear it!
@benwright1988
@benwright1988 3 жыл бұрын
Brilliant video thank you
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
You are welcome Ben!
@tewelebrhane6046
@tewelebrhane6046 Жыл бұрын
You are the best Jim. Please could you come up with videos related with Civil Engineering? since most of the videos are related games or others. Keep it up Jim again you are the best of all.
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Thanks a lot! Will do, new videos to come
@tewelebrhane6046
@tewelebrhane6046 Жыл бұрын
@@jimshapedcoding Can't wait . I am really excited.
@craigleppan7164
@craigleppan7164 2 жыл бұрын
Awesome: dont get the Classes yet but the structure is good Thanks
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Thanks a lot
@harisai-edb
@harisai-edb Жыл бұрын
very well explained
@krishj8011
@krishj8011 2 жыл бұрын
nice tutorial..
@systemtrader1
@systemtrader1 3 жыл бұрын
Super Video!!!
@jimshapedcoding
@jimshapedcoding 3 жыл бұрын
Glad you liked it !!
@sumanabiswas9096
@sumanabiswas9096 Жыл бұрын
Fantastic information
@stevehageman6785
@stevehageman6785 7 ай бұрын
Thanks. :-)
@harrisjeong3999
@harrisjeong3999 2 жыл бұрын
Thanks for this great video! I have one quick question as a beginner. Why did you make a class and put “calculate prime” function in the class? What would be the benefit of making class instead of leaving it as functions?
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Hey Harris, you'll face the benefits as the program grows. Basically, the sign for creating a class should be once you start to have the same parameters for different functions. It's more efficient and more readable.
@munivoltarc
@munivoltarc 5 ай бұрын
give us a notes or a pdf or a ppt, to learn this subject of organize the project or programming in python
@yoyokoko5153
@yoyokoko5153 2 жыл бұрын
great stuff
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
Thanks so much, please share if you can with people :)
@hakimmitiche5447
@hakimmitiche5447 2 ай бұрын
That was usefull
@jimshapedcoding
@jimshapedcoding 2 ай бұрын
Thank you!
@a7medmostafaabuhatab
@a7medmostafaabuhatab Жыл бұрын
Wow
@Iqbalsharib4
@Iqbalsharib4 2 жыл бұрын
How to do it using OOPS?
@jimshapedcoding
@jimshapedcoding 2 жыл бұрын
In the advanced part it is considered OOP :)
@abdelghafourfid8216
@abdelghafourfid8216 Жыл бұрын
Small note, we can simplify the is_prime function like so: def is_prime(num): if num == 1: return True for n in range(2, num): if num % n == 0: return False return true And even more, if you want to make it shorter: def is_prime(num): if num == 1: return True return all(num % n for n in range(2, num))
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Thanks for this, it really shortens the code ;)
@abdelghafourfid8216
@abdelghafourfid8216 Жыл бұрын
Hi, thanks for reply and the great content, here is a one liner too (less readable tho) : def is_prime(num) : return num == 1 or all(num % n for n in range(2, num)
@mysteriousXsecret
@mysteriousXsecret Жыл бұрын
1 is not prime tho
@powergladius
@powergladius 10 ай бұрын
1 is not prime
@Casanova_999
@Casanova_999 Жыл бұрын
Finally now I can stop writing 1 long ass file with 1 function and actually make it readable... THANK YOU.
@jimshapedcoding
@jimshapedcoding Жыл бұрын
You are welcome :)
@azadilful
@azadilful Жыл бұрын
@UlvicanKahya
@UlvicanKahya 2 жыл бұрын
Man, your accent is inarguably Turkish. I'm sure you're Turkish. Are you Turkish? 😄
@Kay-qg1vn
@Kay-qg1vn Жыл бұрын
no he is god-sent 😄
@toolate6971
@toolate6971 3 жыл бұрын
Although I can appreciate your effort, please change the title of your video. This is not about packaging Python projects. Its more about building a Python script using functions, classes and variables.
@malgindesilva2758
@malgindesilva2758 2 жыл бұрын
It is not packaging. It is structuring python project :)
@anonymot
@anonymot Жыл бұрын
Brilliant, keep going
@jimshapedcoding
@jimshapedcoding Жыл бұрын
Thanks a lot!
@wznzgq1354
@wznzgq1354 8 ай бұрын
thank you
Write Python Code Properly!
25:46
Tech With Tim
Рет қаралды 143 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,7 МЛН
7 Tips To Structure Your Python Data Science Projects
14:49
ArjanCodes
Рет қаралды 112 М.
How To Structure A Programming Project…
19:00
Tech With Tim
Рет қаралды 90 М.
Python Magic Methods | Differences between __str__ to __repr__
14:03
JimShapedCoding
Рет қаралды 17 М.
How I Would Learn Python FAST in 2024 (if I could start over)
12:19
Thu Vu data analytics
Рет қаралды 92 М.
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 375 М.
Learn Python With This ONE Project!
55:04
Tech With Tim
Рет қаралды 1,7 МЛН
5 Mini Python Projects - For Beginners
1:41:08
Tech With Tim
Рет қаралды 2,8 МЛН
5 Good Python Habits
17:35
Indently
Рет қаралды 446 М.