472,145 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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?
Expand|Select|Wrap|Line Numbers
  1.     import fs
  2.     import xml.etree.ElementTree as Et
  3.  
  4.     mem_fs = fs.open_fs('mem://')
  5.     os_fs = fs.open_fs(".")
  6.     mem_file = mem_fs.open('mem_test.xml', 'rw')
  7.     fs.copy.copy_file(os_fs, 'test.xml', mem_fs, 'mem_test.xml')
  8.     tree = Et.parse('[string with path to mem_test]')
  9.     root = tree.getroot()
  10.  
Sep 19 '21 #1
1 7374
Vanisha
25 16bit
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.realpath('/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.
Feb 22 '23 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Lost Bits | last post: by
5 posts views Thread by Ian | last post: by
3 posts views Thread by Gregor Wind | last post: by
2 posts views Thread by Kevin | last post: by
18 posts views Thread by diffuser78 | last post: by
12 posts views Thread by David Given | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.