Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17447

Is string a valid type for annotation Sequence[Sequence[str]]?

$
0
0

This is a typical example of a value that can be annotated by Sequence[Sequence[str]]:

[    ['This', 'is', 'the', 'first', 'tokenized', 'sentence', '.'],    ['And', 'this', 'is', 'the', 'second', 'one', '.'],]

I have learned that string is a valid type for annotation Sequence[str], since, loosely speaking, strings are sequences of strings in the Python world. Does that work recursively? Is string also a valid type for annotation Sequence[Sequence[str]] etc.?

I'd say yes, following the Python logic, but I'd say no, following the common sense. And I don't know how to properly test it.


Viewing all articles
Browse latest Browse all 17447

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>