Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 makin hardlinks with pathlib.Path
i see that pathlib.Path.symlink_to exists and is documented. so, i can create a symlink. but i see no means to do a hardlink. i would have expected something named pathlib.Path.link_to to be there to be that. but it does not exist nor is anything like a hardlink documented for pathlib. it looks like i will need to use to make the hardlinks. is there a known way to make a hardlink with just pathlib?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
You can mokey patch.

import pathlib

def link(self, dst, *, src_dir_fd=None, dst_dir_fd=None, follow_symlinks=True):, dst, src_dir_fd=src_dir_fd, dst_dir_fd=dst_dir_fd, follow_symlinks=follow_symlinks) = link
Gribouillis likes this post
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die:
All humans together. We don't need politicians!
if you trace source code of pathlib
you will see that it actively uses os module. Internally, many methods of pathlib.Path class invokes
os.<some_method>. The latter (os), in turn, is based primarily on posixmodule.c.
So, it is possible to create hardlinks using pathlib (joke!), e.g.
import pathlib # will create hard link
... Unfortunately, I think, there is no way to do that the way you want.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Question about if with () or without () / pathlib Tecuma 3 163 Apr-02-2020, 10:02 AM
Last Post: Tecuma
  pathlib hanging bluefrog 2 832 Sep-25-2018, 12:59 PM
Last Post: volcano63
  pathlib: resolving a path that does not exist Skaperen 6 1,251 Sep-08-2018, 12:25 AM
Last Post: Skaperen
  How does pathlib.Path.rename work? wavic 7 5,844 Aug-02-2018, 10:58 AM
Last Post: wavic
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 1,648 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908
  Python 3.6.5 pathlib weird behaviour when resolve a relative path on root (macOs) QbLearningPython 7 2,079 May-29-2018, 08:38 AM
Last Post: QbLearningPython
  pathlib:file in a directory Skaperen 1 976 Apr-01-2018, 03:26 PM
Last Post: Gribouillis
  getting a full path string from a pathlib.PurePath object Skaperen 14 44,344 Mar-24-2018, 03:55 AM
Last Post: Skaperen
  Is pathlib a viable replacement for os.path? j.crater 4 5,531 Jan-13-2018, 09:49 AM
Last Post: Gribouillis

Forum Jump:

Users browsing this thread: 1 Guest(s)