On 2/29/24 7:10 AM, Bruno Haible wrote:
> Argument tests like we have them:
> 
>        if type(actioncmd) is not str:
> 
> are perfectly OK to use. Simple and straightforward.
> 
> is_iterable feels a bit like fashion: You can use them if you want to be
> fashonable and have extra money to spend :)

Fair enough.

> Interesting. Feel free to use this syntax where you find it appropriate.
> 
> I feel it would make sense to use for function returns. For function arguments
> we already have type tests in the essential places.

Sounds like a good starting place. I've noticed alot of the docstrings
contain this information in a similar way [1].

> Probably they would apply here:
> 
>        def cleaner(sequence):
> 
> could become
> 
>        def cleaner(sequence) -> str | list(str):

I think that the correct way to write it would be:

      def cleaner(sequence) -> str | List[str]:

> But since they are only supported starting with Python 3.10, and Python 3.10
> is not on board of e.g. CentOS 8 or Ubuntu 20.04 [1], I would find it too 
> early
> to use this syntax now (except in comments, of course).

Sure, makes sense.

[1] 
https://git.savannah.gnu.org/cgit/gnulib.git/tree/pygnulib/GLModuleSystem.py#n333

Collin

Reply via email to