2

I would like to see whether a file is on the desktop in Mac OS and I write the code:

if path.exists('~/Desktop/AZDif.png'):
    print 'Yes'
else:
    print 'No, the file is not there'

I see the file is not in the Desktop while it was actually there. How to write the code properly ?

Arefe
  • 1,029
  • 5
  • 16
  • 30

1 Answers1

-1

Here is the solution I find for Mac OS using Python:

if path.exists(path.expanduser('~/Desktop/AZDif.png')):
    print 'Yes'

There should also be a way to use absolute path as well. I will check and improve the answer.

Arefe
  • 1,029
  • 5
  • 16
  • 30