Search code examples
python-3.xipythonpathlib

pathlib full list of methods


What is the iPython code/command to list the methods in this case from the pathlib module?

Rationale I use pathlib for example to switch between genetic data file formats. In this example from myfile.txt to myfile.md (markdown),

fileIn = Path.home() / inFile
fileOut = fileIn.with_suffix('.md')

This solution is from Stack Overflow here because the pathlib documentation is limited for this module. There must be inline help?


Solution

  • For anyone who can't be bothered to run inspect.getmembers(Path), here's the list of available functions for Path (as of pathlib 1.0.1, Python 3.8.3):

    absolute
    anchor
    as_posix
    as_uri
    chmod
    cwd
    drive
    exists
    expanduser
    glob
    group
    home
    is_absolute
    is_block_device
    is_char_device
    is_dir
    is_fifo
    is_file
    is_mount
    is_reserved
    is_socket
    is_symlink
    iterdir
    joinpath
    lchmod
    link_to
    lstat
    match
    mkdir
    name
    open
    owner
    parent
    parents
    parts
    read_bytes
    read_text
    relative_to
    rename
    replace
    resolve
    rglob
    rmdir
    root
    samefile
    stat
    stem
    suffix
    suffixes
    symlink_to
    touch
    unlink
    with_name
    with_suffix
    write_bytes
    write_text