python: what is assert? (beginner) anthony explains #240

python: what is assert? (beginner) anthony explains #240

anthonywritescode

3 года назад

21,854 Просмотров

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


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

John Wight
John Wight - 27.10.2023 18:38

Not only did I learn about assert statements but also was exposed to pytest, breakpoint() and pass. Thank you for the great video!

Ответить
nadew
nadew - 03.05.2023 13:14

Thank you for the video. I understood well

Ответить
zouo uoz
zouo uoz - 30.06.2022 13:52

I got an error when trying to do that {x=}

Ответить
Jere Poveda Martínez
Jere Poveda Martínez - 06.06.2022 20:00

Hi, I work in deep learning and I am developing a "framework" for internal use. I want to force the shape of my tensors, I'm doing it with asserts but all the strings dancing around make the code less readable, any suggestions?

Ответить
E W
E W - 17.05.2022 15:29

Why do you state that using "assert" is not a security issue?

Ответить
Akshay Mestry
Akshay Mestry - 18.02.2021 20:52

Also can you please explain what should* be the ideal way to type hint *args and **kwargs in context of being aware of *args and **kwargs arguments. In some cases I'm aware I'll passing all strings as arguments hence I use *args: str (is this correct?) or in some cases where I'm uncertain of the keyword args I tend to use **kwargs: Dict[str, Any] which feels wrong on so many levels but type checkers are fine by it so I usually call it a day and move on. But really wanted to know if there is a `CORRECT` way of annotating *args and **kwargs

Ответить
Akshay Mestry
Akshay Mestry - 18.02.2021 20:46

Does it makes sense to use asserts for building contracts?
The gist is I'm working on a package and in that I want to have a module that enforces module/function/class level annotations. The annotations actually don't help much in the process of execution for the library user but it helps the library itself to find its way around the passed arguments. To solve this I've been watching your videos on `typing` module particularly the overload method video and it has certainly helped. But does it really makes sense to implement that many things (asserts based contracts which enforces types and overload which returns true values) in a library where chances are many user are aware of -O notation and can potentially use it thus disabling the whole feature? I hope I was able to explain my dilemma. This has been bugging me since I started off on the project.

Ответить
JewDude
JewDude - 18.02.2021 19:00

Thanks for the video! Personally I would like to watch videos about best practices for how to structure python projects and repositories for different kinds of projects - web app, bot, command line utils etc.

Ответить
Patskan Team
Patskan Team - 18.02.2021 11:59

-O disables asserts, -OO disables asserts + docstrings

Ответить
hiiiiiiii
hiiiiiiii - 18.02.2021 03:47

Is there going to be a video on PEP 634.??

Ответить
GOZES
GOZES - 17.02.2021 23:22

It would be nice to see a video(s) about working with the python AST :)

Ответить