Re:Show HN: Magentic – Use LLMs as simple Python functions
by smilingemoji on Tuesday September 26, 2023 @03:47PM
(#37664889)
The API looks very clean. Today I learned about "..." in Python
[ Parent
| on HN ]
Re:Show HN: Magentic – Use LLMs as simple Python functions
by quickthrower2 on Tuesday September 26, 2023 @10:33PM
(#37669176)
It is just a noop, but here it looks very appropriate/readable because it reads as saying "AI will fill this in".
Re:Show HN: Magentic – Use LLMs as simple Python functions
by nodesocket on Wednesday September 27, 2023 @03:04AM
(#37671156)
The same as “pass”?
Re:Show HN: Magentic – Use LLMs as simple Python functions
by politelemon on Wednesday September 27, 2023 @03:51AM
(#37671477)
It's a misuse of the Python Ellipsis, though PEP has no opinion on it. The Ellipsis is "Special value used mostly in conjunction with extended slicing syntax for user-defined container data types."
In other words, it happens to work and look neat, but pass is the correct way to do it.
Re:Show HN: Magentic – Use LLMs as simple Python functions
by jackmpcollins on Wednesday September 27, 2023 @12:10PM
(#37676837)
Ellipses is actually used in quite a few places. See the answers and comments on this stackoverflow post[0]. The usage most similar to what I have in the magentic examples is with the `@overload` decorator in the typing module[1].
With that said, you are free to put any code in the function body including `pass` or just a docstring or even `raise NotImplementedError` - it will not be executed. Using Ellipses satisfies VSCode/pyright type checking and seemed neatest to me for the examples and docs. I have some additional notes on this in the README[2].
[0] https://stackoverflow.com/q/772124/9995080
[1] https://docs.python.org/3/library/typing.html#typing.overloa...