What is the function of the ismount method

2

I found some functions of the os module and its submodule path that I am not seeing what they can do:

  • islink
  • ismount
  • Can there be links in the file system?

        
    asked by anonymous 13.10.2014 / 21:42

    2 answers

    5

    Yes, they can. Links ( hard or symbolic) appear on most operating systems and file systems.

    • On Linux you can create a link with the ln command.
    • In modern versions of Windows you create a link with the command mklink , in older versions (XP or lower) you can do this with the junction command.

    Likewise, most operating systems allow you to mount partitions (see the command mount of linux).

    The methods islink and ismount of the module os.path verify if a given path represents a symlink or a mounted partition.

        
    13.10.2014 / 22:09
    3

    islink tells you whether the specified path is a symbolic link , soft link , or symlink ). Previously this type of path only existed on * NIX systems, but recent versions of Windows also support them. They work like a nickname: if a file is in /caminho/pro/arquivo and there is a symbolic link /meu/link associated with /caminho then you can reach the same file through /meu/link/pro/arquivo .

    (In addition to the symbolic links, there are hard links - that work similarly but I have a different internal representation.I suggest opening a specific question if you would like to know more about these types of links)

    Already ismount says if the specified path is a mount . An example in Windows would be C:\ (or D:\ , etc). In * NIX, a path is a mount point if the "parent" path is on a device other than the child path. For example, in /media/cdrom/arquivo the file is on the CD, but the path /media is in the OS itself, so /media/cdrom is a mount point.

        
    13.10.2014 / 22:09