• Troy@lemmy.ca
    link
    fedilink
    arrow-up
    14
    ·
    edit-2
    23 days 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')