On 4/13/2023 1:38 AM, avi.e.gr...@gmail.com wrote:
In Python, "+" does not
mean plus at all. It means whatever the programmer wanted it to mean. An
infix line of code that includes "obj1 + obj2" is supposed to investigate
how to do it. I am not sure if some built-in objects may be different, but
it does a sequence of operations till it finds what it needs and does it.

A really nice example of this is pathlib in the standard library. You can write things like this, overloading the "/" operator:

>>> from pathlib import PurePath
>>> pth = PurePath('c:/') / 'temp' / 'python'
>>> pth
PureWindowsPath('c:/temp/python')
>>> str(pth)
'c:\\temp\\python'

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to