How To Create Custom Exceptions In Python

  Рет қаралды 9,697

Indently

Indently

Күн бұрын

In this video I will be showing you how you can easily create your own custom exceptions in Python easily.
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels

Пікірлер: 33
@softwareengineer8923
@softwareengineer8923 3 ай бұрын
This channel is pure golden. Thanks a lot for another useful content🙏
@AlbieryRodriguez
@AlbieryRodriguez 3 ай бұрын
I really love your videos, I've been learning a lot of them
@ego-lay_atman-bay
@ego-lay_atman-bay 3 ай бұрын
Can you do a video explaining pickling?
@reezuleanu1676
@reezuleanu1676 3 ай бұрын
I only have one question, why would someone want to serialize an exception object using pickle?
@aircommander26
@aircommander26 3 ай бұрын
Nice, thank you for this...
@WedgeDev1
@WedgeDev1 3 ай бұрын
Nice video!
@LegionLeague
@LegionLeague 3 ай бұрын
Pickling an Exception seems pretty random. What are use cases for it? Why would I want to pickle my custom Exception?
@tochimclaren
@tochimclaren 3 ай бұрын
What I'm also asking. Genuinely, I don't know what it's used for.
@VK-qh6pr
@VK-qh6pr 3 ай бұрын
Pickle is just serialising objects. Still confused what he wants to explain by that approach !?
@creed404yt9
@creed404yt9 3 ай бұрын
​I guess it was just a bonus lesson like he didn't want to make a dedicated video for it, also this would make the video 8min ​@@VK-qh6pr
@Indently
@Indently 3 ай бұрын
Personally I have never had to pickle an Exception, but you never know, and it was a free way to include how __reduce__ works for classes that you would like to pickle someday :)
@balazsszalai41
@balazsszalai41 3 ай бұрын
I actually came across a situation where it comes in handy to pickle exceptions. In multiprocessing all the communication between processes is done using pickled data and for example if you handle your exception in a process which then sends its return value to the main program (for example by Pool.map), by pickling the exception you can just send it too and handle it again in the main program properly and know where it went wrong in the other process.
@striatp
@striatp 3 ай бұрын
Your tutorials are awesome! But I was just wondering what IDE are you using? It looks awesome.
@Indently
@Indently 3 ай бұрын
I use PyCharm
@striatp
@striatp 3 ай бұрын
@Indently Alright thanks! 😁
@navidyaghmaei
@navidyaghmaei 3 ай бұрын
Hey love your tutorials. They are amazing. I was wondering though why you didnt use value: any, as it would also work
@tochimclaren
@tochimclaren 3 ай бұрын
Why is pickle important and when is it useful.
@victorgomez6777
@victorgomez6777 3 ай бұрын
Great video! I do have a question: If you want to create a custom exception with only a message I usually do: Class MyException (Exception): ... And it does the trick, ¿Is there a cleaner way to do it? Because it feels kind of bungle 😅
@notLinode
@notLinode 3 ай бұрын
If you just want an Exception with a different class name, that's what you do. I think this won't work in Python 2 though.
@TasCashGr
@TasCashGr 3 ай бұрын
Life goals: "build a library called meeseeks"
@umjames
@umjames 3 ай бұрын
Can do!
@rvft
@rvft 3 ай бұрын
54 likes, zero dislikes
@Indently
@Indently 3 ай бұрын
Where all my haters at? D:
@codures
@codures 3 ай бұрын
​@@Indentlythey await asyncio.sleep(2**32)
@cihansenatak1090
@cihansenatak1090 3 ай бұрын
So, we Can expand try, except in Python with this method.
@Algorithmswithsubham
@Algorithmswithsubham 3 ай бұрын
please make some ios apps
@pabloalonso9083
@pabloalonso9083 3 ай бұрын
What does even pickling means ? 😂
@skewty
@skewty 3 ай бұрын
like JSON but It de-serializes into proper class instances auto-magically. Great for multi-process python sharing.
@skewty
@skewty 3 ай бұрын
the term comes from the process of preserving food for long term storage using pickling (salt brine)
@skewty
@skewty 3 ай бұрын
class HardwareError[T](Exception): def __init__(self, message: str, value: T): super().__init__(message, value) @property def message(self) -> str: return self.args[0] @property def value(self) -> T: return self.args[1]
5 EPIC New Features In REPL (Python 3.13)
9:16
Indently
Рет қаралды 17 М.
Every F-String Trick In Python Explained
19:43
Indently
Рет қаралды 34 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН
Почему Катар богатый? #shorts
0:45
Послезавтра
Рет қаралды 2 МЛН
Air Sigma Girl #sigma
0:32
Jin and Hattie
Рет қаралды 45 МЛН
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 71 М.
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 113 М.
Avoid These BAD Practices in Python OOP
24:42
ArjanCodes
Рет қаралды 87 М.
Why You Need Custom Exception Classes
6:05
ArjanCodes
Рет қаралды 21 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
5 Good Python Practices
23:05
Indently
Рет қаралды 22 М.
5 Uncommon Python Features I Love
15:09
Indently
Рет қаралды 178 М.
What does '__init__.py' do in Python?
12:46
Tech With Tim
Рет қаралды 38 М.
20 Everyday Tips & Tricks in Python
25:18
Indently
Рет қаралды 29 М.
How To Write Better Functions In Python
14:17
Indently
Рет қаралды 58 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН