25 nooby Python habits you need to ditch

25 nooby Python habits you need to ditch

mCoding

2 года назад

1,761,185 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Jorge Rusailh
Jorge Rusailh - 16.09.2023 19:04

Your voice make me think in Adam Something.

Ответить
Viktor Ferenczi
Viktor Ferenczi - 15.09.2023 05:47

I would add one more: Confusing `a is T` with `isinstance(a, T)`. It is common for devs coming from C#, because the `is` operator means that there. I even make this mistake myself should I switch between the two languages frequently.

Ответить
Cuptiul
Cuptiul - 14.09.2023 22:43

When I saw the thumbnail I thought using PyCharm would be one of the noob techniques.

Ответить
etrestre
etrestre - 10.09.2023 16:26

Are you coding in Windows?

Jesus...

Ответить
Sebastian
Sebastian - 10.09.2023 14:14

Number 6 had me go "wow, what a bad language feature this is".

Ответить
TheDiscoMole
TheDiscoMole - 10.09.2023 01:14

All good except that time.time isn't noob, perf_counter is vegan.

Ответить
fluffy
fluffy - 09.09.2023 10:40

I'm happy to say I do absolutely none of those things, and a big part of that is that I use pylint which detects those issues and tells me they're wrong (and autopep8 to follow pep8 because I have better things to do than manually format my operator whitespace)

Ответить
sharpfang
sharpfang - 08.09.2023 23:31

Any good resource on #22? I'm writing a Python module but no clue how to turn it into actual, redistributable module instead of a file you must put in same directory as your program.

Ответить
Marko
Marko - 08.09.2023 08:44

I'll have to disagree with number eleven. Everything being "truthy" was a mistake, and the "nooby" examples are probably always more readable. I would always prefer the second one, personally.

Ответить
Harry Pray IV
Harry Pray IV - 07.09.2023 23:48

#1: using Python

Ответить
Alexandru Mazâlu
Alexandru Mazâlu - 07.09.2023 02:12

slapping the like button an odd number of times will not end up with the video liked

Ответить
Joseph Chillemi
Joseph Chillemi - 06.09.2023 15:21

if check:
If check2:
if check3:
if check4:
print('what about nested if statements?')
else:
print('meh')
else:
print('you forgot nested if statements')
else:
print('nested if statements are the devil')

Ответить
Mutantcy1992
Mutantcy1992 - 06.09.2023 09:17

it's pronounced tuple

Ответить
Alain Richardt
Alain Richardt - 05.09.2023 10:02

Formatting PEP8 is not to avoid the nagging of others, it serves two important purposes: 1) It lowers the cognitive burden of understanding the code because your attention is not constantly being distracted checking for equivalence and 2) It means source control changes are focused only to important differences rather than a bunch of style inconsistency noise

Ответить
ofnotandi
ofnotandi - 05.09.2023 03:25

I do a bunch of this because I need technicians to understand my code. I will write I = I + 1

Ответить
arpit gupta
arpit gupta - 05.09.2023 00:53

For bool/len check, it is always a good idea to specify bool/none type checking. Eg: If a function returns bool and return value check is like 'if not x' and there is an exception in function, then 'if not x' will be false, which is incorrect.

Ответить
k9elli
k9elli - 04.09.2023 10:14

I came here to learn the nooby tricks so I can use them

Ответить
Andrew Truttmann
Andrew Truttmann - 04.09.2023 02:51

Note to myself

Ответить
Sky Leonidas
Sky Leonidas - 03.09.2023 11:06

Shit i didnt know the default was looping over the dict keys, but i still think using .keys() is more readable

Ответить
Krisztián Fekete
Krisztián Fekete - 01.09.2023 23:54

Thanks I didn’t know the .keys() is the default for for each 😁 also I am still going to use range(len(list)), sometimes I like a plain for cycle better 🤷‍♀️

Ответить
Elena Kusevska
Elena Kusevska - 01.09.2023 04:39

Enumerate is such an unnecessary complication and unreadable. If you need to count, just count like you would in any language, there's no harm in doing it occasionally :) By the way I frequently do the simple string concatenation when I'm too lazy to do f strings if it doesn't matter for the particular case. Also formatting with f strings is not always exact. I think it doesn't matter how you choose to do something. If you have an understanding of the language, how it handles memory, etc. That's the most important thing. Keep it clean and readable :)

Ответить
Pascal Müller
Pascal Müller - 01.09.2023 01:03

I think I'll always prefer loops over list comprehension. Explicit code is good code. List comprehension always are a mess, just bad to read.

Ответить
Mikko Finell
Mikko Finell - 31.08.2023 23:37

Sorry but pep8 is the hobgoblin of little minds.

Ответить
Karam Thethy
Karam Thethy - 31.08.2023 20:35

0/10 cant pronounce tuple

Ответить
Todor Popov
Todor Popov - 30.08.2023 16:35

# pycharm

Ответить
Noone Atall
Noone Atall - 30.08.2023 03:08

Watching videos that GPT can program better. 8)

Ответить
Chaos Ordeal
Chaos Ordeal - 27.08.2023 01:15

At first I was going to comment that my hacky Python skills are totally up to my needs, but then why would I be watching this video? Well, I did learn something interesting, so maybe the video really was for me, so I decided not to comment at all.

Ответить
sandesh sukubhattu
sandesh sukubhattu - 26.08.2023 17:44

using is operator is risky. Don't just brag yourself in video.

Ответить
TheDbzgtaf
TheDbzgtaf - 26.08.2023 06:16

I don't even know most of the mistakes, let alone their correct versions 😭

Ответить
T W
T W - 25.08.2023 00:44

Nice!

Too bad the 'before' and 'after' versions couldn't be on the screen at the same time for comparison.

Ответить
Johnny Campos
Johnny Campos - 23.08.2023 10:22

This actually made me feel a lot more confident about where I am in my Python learning journey. I expected to fail all of these but I actually consistently do most of the things you recommend!

Ответить
Gagandeep Singh
Gagandeep Singh - 22.08.2023 00:30

For me, one of the major rookie mistakes was to not clearly understand the namespace.
I have spent hours trying to debug a perfectly written notebook code, just to find out I replaced the inbuilt sum function with one of my own.

Ответить
Pangawack
Pangawack - 20.08.2023 10:47

Jeez LaWEEEEZ, papa cheese!
I don't even know enough python to make these nooby mistakes! O.O

Ответить
Alex Watson
Alex Watson - 18.08.2023 21:16

Looping over keys() is fine and actually encouraged by the Zen of Python, i.e. explicit is better than implicit.

Ответить