Good video, but what about some functions that return some type but have the body containing only "..." and no return statement, in example: def function(x:int) -> str: ... What does this do ? Is it like an abstract function, alike a placeholder for later implementation ? How does one debug this to see where it proceeds to ?
I believe I covered those in the video but I will reiterate: - the function doesn't do anything, just returns None (`...` is an expression statement in that context) - that's often used to write type stubs (.pyi, overloads, protocols, etc.) - or just to demo things
`...` and `Ellipsis` refer to the same builtin object but you can put three dots in a repr and it's entirely separate (as it's just a string) ``` class C: def __repr__(self) -> str: return 'C(...)' ```
I'm curious, .. why don't you have an alias command for: "virtualenv venv, venv/bin/activate, pip install mypy, mypy t.py" yet? It would have saved you at least an hour of typing by now. It's almost at every "anthony explains" :-)
Thank you for the video. I am grateful for your time and contribution. Kind regards, Akira.
Good video, but what about some functions that return some type but have the body containing only "..." and no return statement, in example:
def function(x:int) -> str: ...
What does this do ? Is it like an abstract function, alike a placeholder for later implementation ?
How does one debug this to see where it proceeds to ?
I believe I covered those in the video but I will reiterate:
- the function doesn't do anything, just returns None (`...` is an expression statement in that context)
- that's often used to write type stubs (.pyi, overloads, protocols, etc.)
- or just to demo things
maybe I missed but have you talk about the closures?
a = []
b = a
b.append(a)
print(b) -> [[...]]
that's not a closure, that's a recursive repr (and not part of the syntax)
@@anthonywritescode ops you are right about recursive representation but I thought that it [...] is an ellipsis sign?
yes and no, three dots is an ellipsis but reprs are just strings (it's replacing an un-representable portion of the object) and not syntax
@@anthonywritescode so '...' is syntax, not the Ellipsis object?
type(return me not Ellipsis)
`...` and `Ellipsis` refer to the same builtin object
but you can put three dots in a repr and it's entirely separate (as it's just a string)
```
class C:
def __repr__(self) -> str:
return 'C(...)'
```
Maybe you should become a teacher, at a college or bootcamp, etc.
Like and Thx Bro! But where is source mypy? For what pip install mypy?
to find the source I usually search "github python package name" -- or you can look on pypi as they are often listed there as well
Amazing talk:)
I'm curious, .. why don't you have an alias command for: "virtualenv venv, venv/bin/activate, pip install mypy, mypy t.py" yet?
It would have saved you at least an hour of typing by now. It's almost at every "anthony explains" :-)
lol, well the problem with aliases is they're super confusing in videos. and I type fast enough that they're not super beneficial to me
thanks for this it was useful
thank you
Thank you for the video. But why does it say "views..." only on your video. First I thought I was tripping.
weird, maybe a youtube A/B test? I don't see it myself
Cool, gitub profilepic shirt :-) (as of time of this comment :D )