型を調べたり
>>> type(sys.stdin)
<class '_io.TextIOWrapper'>
属性を見たり
Python
1>>> dir(sys.stdin)
2['_CHUNK_SIZE', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_checkClosed', '_checkReadable', '_checkSeekable', '_checkWritable', '_finalizing', 'buffer', 'close', 'closed', 'detach', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'line_buffering', 'mode', 'name', 'newlines', 'read', 'readable', 'readline', 'readlines', 'seek', 'seekable', 'tell', 'truncate', 'writable', 'write', 'writelines']
ヘルプを見たり
Python
1>>> help(sys.stdin)
2長いので省略
ドキュメント見たり
Python
1>>> print(sys.stdin.__doc__)
2長いので省略
アノテーション見たり
見られるとは限りませんが。
Python
1>>> def add(a: int, b: int) -> int:
2... return a + b
3...
4>>> add.__annotations__
5{'a': <class 'int'>, 'b': <class 'int'>, 'return': <class 'int'>}
6>>>
7>>> print.__annotations__
8Traceback (most recent call last):
9 File "<stdin>", line 1, in <module>
10AttributeError: 'builtin_function_or_method' object has no attribute '__annotations__'
対話環境で色々調べられるので便利です。
戻り値の型などはあまり意識しなくてもよい、柔軟な言語だと思っています。