What is the path to a Virtual Memory file created in python?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yuriachermann
    New Member
    • Sep 2021
    • 1

    What is the path to a Virtual Memory file created in python?

    I'm trying to create a virtual XML file, copy some content to it, then access throw parsing, it may be simple, but every path that I'm trying to use ( like 'mem://mem_test.xml' or '{}'.format(mem _file) ) are not working... What path should I use to access a file in the Virtual Memory?
    Code:
        import fs
        import xml.etree.ElementTree as Et
    
        mem_fs = fs.open_fs('mem://')
        os_fs = fs.open_fs(".")
        mem_file = mem_fs.open('mem_test.xml', 'rw')
        fs.copy.copy_file(os_fs, 'test.xml', mem_fs, 'mem_test.xml')
        tree = Et.parse('[string with path to mem_test]')
        root = tree.getroot()
  • Vanisha
    New Member
    • Jan 2023
    • 26

    #2
    In Python, the path to the Virtual Memory file depends on the operating system being used.

    On Windows, the Virtual Memory file is typically located at C:\pagefile.sys .

    On Linux, the Virtual Memory file is typically located at /swapfile.

    In general, you can use the os module in Python to obtain information about the Virtual Memory file. For example, to obtain the path to the Virtual Memory file on Linux, you can use the following code:
    import os
    path = os.path.realpat h('/proc/swaps')

    This will return the absolute path to the swaps file, which contains information about the swap space being used on the system.
    If you're looking to improve your coding skills or learn new technologies, join Cetpa Infotech.
    Check out our website for more information.

    Comment

    Working...