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