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