User Controls

os.remove fails without raising error(Python)

  1. #1
    Sophie Pedophile Tech Support
    Ok so i am trying to remove a file from the working directory with the os.remove syntax. It doesn't raise an error so it appears to have worked. But it hasn't and it's critical that it does work for the operation of my program. So then i was thinking, perhaps i need the absolute path to properly remove it.


    import os

    path = os.path.abspath("my_file.p")
    os.remove(path)


    Again no dice, the file extension is .p because the file contains data that has been pickled by Python. It might be important to note that this file has been read in by python before the deleting operation is performed. But again, if it was impossible for Python to access the file shouldn't i be getting an IO error?

    Furthermore, after the os.remove syntax i tried `os.system("rm -rf my_file.p)` which didn't work as well. Any ideas?

    Post last edited by Sophie at 2017-03-15T21:47:52.298867+00:00
  2. #2
    Sophie Pedophile Tech Support
    Oh wait a sec, i have my remove operation inside a conditional so let me check if that's the problem.
  3. #3
    Sophie Pedophile Tech Support
    Disregard it was my conditional ( ͡° ͜ʖ ͡°)
Jump to Top