I don't have a machine available right now, but I wonder what happens if two adjacent path elements are integers? Does it perform division instead of path/string concatenation?
>>> Path.cwd() / 1
TypeError: argument should be a path or str object, not <class 'int'>
Also, note that the '/' operator is left-associative, so even if you have two adjacent numbers when joining paths, there will be no division. TypeError: expected str, bytes or os.PathLike object, not int >>> from pathlib import Path
>>> p=Path(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/pathlib.py", line 979, in __new__
self = cls._from_parts(args, init=False)
File "/usr/lib/python3.6/pathlib.py", line 654, in _from_parts
drv, root, parts = self._parse_args(args)
File "/usr/lib/python3.6/pathlib.py", line 638, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not int
>>>
So what happens if the paths are numbers? They are treated like any other characters.Python is strongly typed.
Should I have said "numeric characters" or "numeric strings" in my last paragraph instead of numbers?