0

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?

M__
  • 614
  • 2
  • 10
  • 25
  • 1
    Does [How to list all functions in a Python module](https://stackoverflow.com/questions/139180/how-to-list-all-functions-in-a-python-module) help you here? – hemmelig Jun 27 '20 at 17:12

2 Answers2

1

With thanks to @hemmelig

import inspect 
from pathlib import Path

inspect.getmembers(Path)

and for a more detailed description,

help()
>pathlib

Easy when you know how.

M__
  • 614
  • 2
  • 10
  • 25
1

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
Dash
  • 1,191
  • 7
  • 19