Комментарии:
I have always found the "pythonic" version of code to be non intuitive. I like the traditional if statements.
ОтветитьOne line if statements should be forbidden.. it is so unreadable, ugly.. nah no thanks man.
ОтветитьGreat advice, did not know "any" . Thanks a lot
ОтветитьThirst for learning . This channel is a good one to quench
Ответитьpython is beautiful than javascript but ilove them both xD nice video!
ОтветитьI'm trying to become a data engineer and Python is my first coding language. My goal is to improve my programming skills and this video is super helpful to me.
ОтветитьI have no idea why but I have always been doing these 8 things. I'm not even a good programmer but I guess a lot of trial & error gives you a bit of intuition about what seems more readable.
ОтветитьHuh, I refactore my code alike.
ОтветитьPython Engineer, you are amazing!
ОтветитьThanks for those tips, they are great! I have been refactoring a lot of my code lately, guess it shows I am progressing 😀 So refactoring tips: YES PLEASE! Great vid format as well 👍
ОтветитьThanks a lot! Tips about "any" statement, assigning variables closer to their usage and guard statements to remove excessive indentation were very nice.
ОтветитьI write nested if expressions and have written a nested list comprehension which was 3-4 levels deep, can't even debug it anymore, it just works and no one knows why now.
Ответитьthese are true for any language, but good tips indeed
ОтветитьPatrick, just subscribed too your channel. Love your work. I waa trying to find out where you're from. You sound Canadian ie Letterkenney vibe.
ОтветитьNah, just right click on random code and click your IDE's "refactor" button and trust that your code is better. I'm a profession programmer.
ОтветитьThese are all style fixes that do not affect readability or function. Are you changing working code just to satisfy your subjective sense of beauty? Please don't work for me.
ОтветитьFor #6 since you aren't computing anything inside the if statements, you can also just do
return weather.is_raining or is_stylish
Does this make sense to others?
why u gotta sound like that bro
Ответитьwhat theme do you use for the ide?
ОтветитьGreat tips. Thanks
ОтветитьReally high information density on these vids. Very nice and not often seen.
Ответитьthank your tips, your code font is also beautiful, i like it, Can you tell me which one font?
Ответить#4: `var=something; return var` has its place: debugging.
ОтветитьNice. Subscribed!
ОтветитьI follow every tips except the inline condition due to readability and any(list) because I forget 😂
ОтветитьI prefer to only have return per function, it's much cleaner and easier to debug.
Returning results as the var IMO is best practice. It allows you to easily debug and read the code
output = 'hello' * 2
return output #> 'hellohello'
That advice is only true when dealing with large numpy arrays where creating the variable is time consuming.
Update: any(generator) --> Stops at the first true result of the generator, without processing the rest. Which is very useful and something I'm glad I now know
Original comment:
Can someone run that any( check
I believe the whole generator is first evaluated then any checks the result.
If so this is not what you want on most large datasets
Excellent video. Thanks!
ОтветитьYou should definitely do more code refactorings
ОтветитьWhy not use python black directly?
ОтветитьFor number 5 (if expressions), then I think the if expressions can simplify code assuming that the code is not too long. For your example, I think that the shortening does not make it less readable. However, for if-else statements with longer assignments and conditions, the shorthand if expression can make the readability go way down (this is the same problem that long list comprehensions have). There is also the disadvantage that programmers from other languages can find the syntax a bit weird (although ternary operators still exist in e.g. JavaScript).
I've purposefully avoided using the if expressions in my videos since I am not sure that everything knows about them. However, I think it would be good if more people knew :)
#5 How about:
x = 1
if !(condition):
x = 2
#7: last else is unnecessary.
Well balanced information. Concise. Thanks.
ОтветитьHi Patrick,
Great video as always! Thanks for sharing your knowledge!
Also, your new Website design is outstanding. 👍
Beste Gruesse,
Sven
Love the new video! 🔥
ОтветитьThanks for the 8th tip, it is useful.
Actually, your all tips are great and useful, Nice tips
I don't even use Python but I am a simple man, If you upload I watch 😎
ОтветитьWhich VS Code Theme you are using Sir?
ОтветитьGood tips, thanks! Personally, I don't like returning an expression directly without assigning to a variable. When you use a variable, it is easy to add a breakpoint without refactoring if you need to see the value before it is returned.
Ответитьmore pls.
ОтветитьNice.
ОтветитьWhen You're First So You Don't Know Wut To Comment 🤔...
Ответить