Комментарии:
Learn to use PyCharm not visual studio because what you did in the 8 minutes of your code will be done automatically with it.
Ответитьcomments are useful
ОтветитьInstead of doing all this, why not just use a linter like flake8 / black which will fix a lot of the issues you fixed manually
ОтветитьWhat program is he using to use python? For example, is it Spyder or what is it?
ОтветитьForgot to pass the new golf_ball variable when calling the find_angle fuction.
ОтветитьI suppose all those missing white spaces and amount of empty lines between functions could be handled with something like autopep8, black or yapf
ОтветитьLoved the video and the resources! Thanks for sharing
ОтветитьWhy not use an ENUM for colours?
ОтветитьThanks for an explaination Tim. I like a theme you using in your vscode. Can you share a name of theme Tim?
ОтветитьInteresting. Thank you
ОтветитьThe return on line 33 wasn't changed to reflect the new variable names.
ОтветитьYou forgot to replace the (0,0,0) at line 25 with the constant BLACK you created.
ОтветитьMore clean code videos!
ОтветитьSorry, but the first striking thing that this code needs is comments.
You can embellish your code all you like with spacing and snake casing, but comments will make it more readable and easy to understand (and refactor).
This video gives me anxiety.
ОтветитьBeginner here. Is commenting on the code would be seen as bad coding practice? And if not necessarily, what is considered good commenting?
ОтветитьSnake case for functions? That looks a bit ugly.
ОтветитьHey this is great, your code is A++, but another thing to make your code even better is to add a little more comments throughout your exceptional code!😎😇👍✌️😸
ОтветитьI will never leave camel and pascal case
ОтветитьThis is on a whole new level of programming asmr
ОтветитьYou just made it harder for a begineer to understand 😂
ОтветитьIf you use Python then your code already isn't clean, because Python have a lot of useless things on their binaries making the code heavy with a very poor performance.
ОтветитьFor most of these you couda just ran this in pycharm and it would have listed out all the format errors ;-;
ОтветитьIt's better most of the times to use try/except, because of "easier to ask for forgivness than for permission" or something it was going around :)
ОтветитьSuper helpful vid!
ОтветитьMight be fun to do a type of competition where you ask your viewers to refactor a piece of code like that.
Then we could all learn from the best out of those.
More things
Always add comments to your methods functions
ball_path should be called path because you are repeating yourself when calling it
Win, pos, vec are not obvious you need to state what these are and how they are used
Your try block should have except Exception as e: print(e) so you know when an error happens
golf_ball could be just ball, as you don't have any other types of balls on the field.
Always copy and paste very names to avoid mistakes Tim made
Always make a backup copy of the file before you refacter
Add comments to complex logic so you can just read why its happening rather than how it happening
run variable is uneeded as you are only using it once
Add comments at the top to what this program does, potential issue and future ideas and also add links to common documents like pygame docs
Your continue block was unneeded and will cause issues later when you have other mouse actions
Add type checks using assert as a sanity check to make sure everything is the excepted type of thing. Especially using tuple deconstruction you will have add errors if pos happened to have a length of three for example.
I typically write all of the function names in the document at the top of the page in a comment so I know what I'm dealing with when I open the project after a long time.
Pretend you are writing the code for a future more retarded version of yourself.
even though you forgot like 5 things, you made your point clear and that's what this video is about, so great video
Maybe you could've pointed out that making comments is good practice, also maybe could've said that if you've a lot of and's that you can put them below each other instead of next to eachother and maybe try and avoid if statements, they're not efficiënt and also in a lot of situations not the cleanest solution.
good stuff tim !
ОтветитьOne question: in the main loop, don't you need to see first events then movement and visualization?
ОтветитьI am not so bothered by convention but I totally agree with being consistent whatever you decide to use. I would also prefer to have separate functions for the various code blocks personally but as long as others and of course you can understand your code when you have to revisit it to make changes months or even years later that's what matters most.
Ответитьthanks bro 👍🙂
ОтветитьWell i just finish 12 hour video when is the new one?
ОтветитьDo you think you could help me with a pycharm opencv project? im not a coder and the code is ready but I dont know how to put it together to run it...
ОтветитьI'm currently working on a puzzle game, which users can grab the element pieces to fill in a grid.
Using the Tetris method to create grid and interface, so far so good, but I cant find any tutorial where I can grab an object (NOT an image) on screen.
How can I drag elements that is in pygame?
Gr8 vid as usual : )
ОтветитьIf I have a single line after an if statement I write it as:
greeting = 1
if (greeting) : print("Hello")
else: print("Bye")
Is this a good practice?
The try-except case is a really good one to demonstrate the importance of clean code - had you used a more specific exception (ZeroDivisionError), you would have easily known what the error could be there, without having to remember trigonometry! :)
In my opinion the point there might have been slightly missed - it isn't about sticking to best practices with an if-else statement, it's about making the code easier to handle, especially when returning to it after several years
Anyway great vid, love the uploads lately :)
Keep up the good work Mr. Tim
ОтветитьLoved this man! Thanks🙌
Ответитьfabulous
ОтветитьAnd why using atom here?
ОтветитьI like camel case way better.... Not sure why python decided to use shake
ОтветитьYou should use atan2 in your find_angle method, instead of redefining it ;-)
ОтветитьYou're like telling me i have clean code, Thanks man Lol
ОтветитьWonderful video, I wonder if you can discuss a better way to address "if elif" and "if if" blocks
ОтветитьDude you are gold for this sphere very very well explained 👍👍 for the young guys don't worry your brain can't take too much unless you are giny who is rare, but who knows anyway gg Timaty 🙃✌
Ответить