python: raise SystemExit (beginner - intermediate) anthony explains #331

preview_player
Показать описание


==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

I think this looks more readable as well.

AceofSpades
Автор

Can you please do videos on AWS as well?
Recently I've been working a LOT on AWS, particularly Lambdas. And I often wonder what would be the best way of writing the code. I type hint, lint, write tests and add docstrings on all the callable objects but I still don't feel confident when it comes to best practices. So I request you make videos on your take when it comes to working with AWS. I love to watch you work with AWS mostly on your streams but it feels its just a glimpse and doesn't cover your thought process.

akshaymestry
Автор

Now that I'm looking at this for the 3:rd time, in order to get the new pattern into my brain ;-) I believe that in order to make your example work, I'd still have to import the sys module, and use "raise SystemExit(main(sys.argv))" versus "sys.exit(main(sys.argv))" - which would not save that many characters anymore...
Is there something I'm missing?

Huge thanks for all your videos, and especially the explanation of exit() vs sys.exit() in this one!

magnuscarlsson
Автор

Why is exit() or SystemExit() needed at all? What’s wrong with just calling main() by self?

AdrianMoisey
Автор

Hi Anthony

During watching your video a question sprang into my mind. Does that solution fit into the graceful shutdown principle?
Do you have any idea what is the appropriate way to close running connections _( connections with some resources )_ when something wrong happened in the script?

Thanks for the answer in andvance.
BR, István

istvanhornyak
Автор

Sir Anthony Hi

I want publish a CLI package but I don't know how can I make that accessible in all linux directories. (what is best practice ?)
Can you please make video about that. please please <3

I think many needs videos about packaging and publishing in general.

mrj
Автор

Is there much of a difference between ` raise SystemExit(main())` and `main(); raise SystemExit()` I've never come across the syntax you use before and wonder if there's an advantage.

tommacnamara