I don't know how he does it but Anthony always manages to leave me speachless. Here I am thinking that I know Python quite well yet he always finds something to demo that makes me go O_o
I have a question in pycharm I have interpreter 3.10 do I have to check the checkbox code inspections have incompatible with other Python versions then it produces red underlines with like tkinter it says incompatible with Python 2.7 version? Thanks
to support other class instances as a right part of comparison/arithmetic operation that you don't know how to work with but they may know how ```python >>> 1 + MyNumberClass() ``` without `int` returning `NotImplemented` for `__add__` it won't be possible to use an overload in `MyNumberClass.__radd__` since `NotImplementedError` will be raised (and they can be raised by anything down the road while every function directly controls what it `return`s)
I explained the reason for that at the end! (note that in addition to the reasons I state in the video it's not raising also, it's returning -- exceptions aren't part of the type system)
That's annoying. Is there a way to circumvent that somehow? I guess you could have tests that catch that but testing types in tests is not my favorite thing...
So much of watching this for me is "That's weird... no, actually, that makes sense unfortunately"
I don't know how he does it but Anthony always manages to leave me speachless. Here I am thinking that I know Python quite well yet he always finds something to demo that makes me go O_o
Very nice video! False being a float I kinda expected but I honestly didn't know that the NotImplemented class existed.
there's more about NotImplemented linked in the description too if you're further curious
@@anthonywritescode I am sure I will get to it, I am currently at ~200th video of this playlist. It is very fun and informative to watch. :)
We must simply respond "fair enough"
NotImplementedType can be found in the types module (!= typing), along with other useful types (NoneType, EllipsisType, etc) :)
I have a question in pycharm I have interpreter 3.10 do I have to check the checkbox code inspections have incompatible with other Python versions then it produces red underlines with like tkinter it says incompatible with Python 2.7 version? Thanks
What I wonder is, why have these quirks in the typing system instead of expecting __lt__ to raise NotImplementedError instead?
to support other class instances as a right part of comparison/arithmetic operation that you don't know how to work with but they may know how
```python
>>> 1 + MyNumberClass()
```
without `int` returning `NotImplemented` for `__add__` it won't be possible to use an overload in `MyNumberClass.__radd__` since `NotImplementedError` will be raised (and they can be raised by anything down the road while every function directly controls what it `return`s)
I explained the reason for that at the end! (note that in addition to the reasons I state in the video it's not raising also, it's returning -- exceptions aren't part of the type system)
That's annoying. Is there a way to circumvent that somehow? I guess you could have tests that catch that but testing types in tests is not my favorite thing...
you could maybe do something with NewType though I haven't found a reason that this detail breaks me yet to rationalize the complexity of NewType
you can also use beartype which allows for type algebra and can easily define a float that isn't a int.
if not 0.0:
print("python is a scripting languagle")
Not implemented seemed kinda normal to me. Isn't not implemented usually a bottom type in other type systems?