I have found the following python function definition:
def reverseString(self, s: 'List[str]') -> 'None':
I don't quite understand 'List[str]' and -> 'None'.
I have found that the arrow is a function annotation but I couldn't find anything useful and understandable for List[str].
Is it just an annotation? or does it enforce that the type of parameter s must be a string array?
It's a function annotation. In more detail, Python 2. x has docstrings, which allow you to attach a metadata string to various types of object. This is amazingly handy, so Python 3 extends the feature by allowing you to attach metadata to functions describing their parameters and return values.
Python doesn't use arrow notation, like JavaScript — so what is this arrow doing? This, friend, is a return value annotation, which is part of function annotation, and it's a feature of Python 3 - and has been here since 3.0!
Practical Data Science using Python The asterisk (star) operator is used in Python with more than one meaning attached to it. For numeric data types, * is used as multiplication operator >>> a=10;b=20 >>> a*b 200 >>> a=1.5; b=2.5; >>> a*b 3.75 >>> a=2+3j; b=3+2j >>> a*b 13j.
Arrow is a Python module for working with date and time. It offers a sensible and human-friendly approach to creating, manipulating, formatting and converting dates, times and timestamps. It allows easy creation of date and time instances with timezone awareness.
It's just python type hinting, You can learn more in PEP 484
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With