• Troy@lemmy.ca
    link
    fedilink
    arrow-up
    8
    ·
    edit-2
    9 hours ago

    It’s also a really fun example of operator overloading. __div__ is overloaded to allow this syntax.

    >>> p = PurePath('/etc')    
    >>> p    
    PurePosixPath('/etc')    
    >>> p / 'init.d' / 'apache2'    
    PurePosixPath('/etc/init.d/apache2')