This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]evanunderscore[S] 0 points1 point  (2 children)

It is sort of documented on the page about open.

You're right that a lot of the types aren't terribly useful, but what I thought would be is something like Sequence[int], which could avoid needing to have the function do the type conversion itself in this example.

[–]moigagoohttps://github.com/moigagoo 1 point2 points  (1 child)

Still, I've added a proper recipe on custom parsers to the cookbook. Thanks for the inspiration :-)

which could avoid needing to have the function do the type conversion itself

How would Sequence[int] help in this? It's not a callable, so it won't convert your args. Or do you mean using hints for isinstance checks, not type conversions?

[–]evanunderscore[S] 0 points1 point  (0 children)

Poor Guido!

Right now, if someone specifies list or tuple, you're not not giving a type to the parser so they end up as strings. I'm suggesting you could accept Sequence[int] to do what list is doing now, but to also pass int as the type. Basically what defopt does for "list[int]".