Only Real Pros Use THIS In Python #python #programming #coding

preview_player
Показать описание
Only real pros use this in Python. from typing import NoReturn
Рекомендации по теме
Комментарии
Автор

I have not seen a single "python pro" do this 😭

jp
Автор

This man annotates his code like he's being paid per character

SonOfMeme
Автор

also for functions that use "exit" or similar sys-terminators

zmipdkq
Автор

At this point, we're almost better off requiring that a return type be declared when creating a function in Python. If annotating the return type is becoming the mainstream convention for writing "good" python code, why not just make enforcing a return type a part of the language, or at least an optional feature?

imma
Автор

We don’t use THIS in Python. We use SELF.

jshell
Автор

None is like undefined and null combined lol

xijnin
Автор

Looks strange to create a function, which always raises Exception

georgiyveter
Автор

Now i always use type annotation and return type

LUCAS-luii
Автор

I feel like Python is just a collection of one off features with little consistency (or enforcement) among them. In static typed languages, this is just the concept of a void function. Nothing new or exciting. I do try to like Python, but few things in the language actually feel like they were well thought out. Type hints are a new-ish feature and yet python has been returning None from void functions probably since the beginning. This means for several years there wasn't a way to simply denote a void function until recently.

pharoah
Автор

I only did this for a big project I had in my first year CS. My team was pretty much full of newbies so I commented every line of the code I wrote and I also wrote what type each of the parameters are and what the function returns. When my teacher checked our project he came in our class and said "You guys are either pros or you've used chatGPT" and I started laughing (which made it more suspicious as he thought it was chatGPT lol).

ItzMeKarizma
Автор

make a videos of devin ai please😭😭😭🙏🙏🙏

enderman-kqwq
Автор

Where to get list of Packages or Modules available in python ? Just like you used typing module

AMagicViewer
Автор

Doesn't PEP 8 state that return can be omitted, as long as there isn't a single function returning anything but None. If that isn't the case all functions should have a return statementm including an explicit "return None".

fg
Автор

i think the reasoning behind this is a little silly. If this function is exposed in a library you should already have a proper docstring that makes clear what it does or doesn't return anyway. if it's a private function, it depends on what code style convention you use, which is usually either type hinting everything or nothing, not just "none".

experimentalcyborg
Автор

Maybe? For me return and function its works like this:
When you want to print 5 + 5 you gina get 10 cuz print always printing result and same with function. It gives none cuz its dont have result, but with "return" you saying wich result your function should have. Sorry for my eng and bad knowledge its just the way how i understand functions and " return " stuff

MynameisZOOM
Автор

next thing you'll say is we should comment our code. I don't want other people to understand what I wrote. I'm not gonna make it easy for them.

Robert-qwlr
Автор

Wouldn't theoretically a function without a return be called a procedure?

twilightgroveenthusiast
Автор

I was already using None, but I didn't know there was a NoReturn typing, too. I'm just not sure what the difference is between the two. How does it effect type hinting while working within VSCode or PyCharm? How would it flag an error when the variable you try to assign the non-existent return value to it? In other words, while I get None is more or less Python's version is void or nil, what is the closest NoReturn equivalent?

bigk
Автор

Or you could switch to a better language that doesn't force implicit typing and return void functions.

sporksto
Автор

Your shorts always make it seem like you're about to preach something mind blowing but this is just basic info. Nothing "pro" about it.

dariuselijah