python pathlib operator ‘/’ – how does it do it?

The Path class has a __truediv__ method that returns another Path. You can do the same with your own classes:

>>> class WeirdThing(object):
        def __truediv__(self, other):
            return 'Division!'

>>> WeirdThing() / WeirdThing()
'Division!'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)