Skip to content

Instantly share code, notes, and snippets.

@vrunoa
Created November 24, 2015 00:27
Show Gist options
  • Save vrunoa/f89e8b1878433cea0746 to your computer and use it in GitHub Desktop.
Save vrunoa/f89e8b1878433cea0746 to your computer and use it in GitHub Desktop.
Unlink in python
@pamepros
Copy link

Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> PATH = lambda p: os.path.abspath(
...     os.path.join(os.path.dirname(__file__), p)
... )
>>> os.unlink(PATH('/android-sdk-linux'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in <lambda>
NameError: global name '__file__' is not defined

@vrunoa
Copy link
Author

vrunoa commented Nov 24, 2015

try

import os
__file__ = os.getcwd()
PATH = lambda p: os.path.abspath(os.path.join(__file__, p))
os.unlink(PATH('android-sdk-linux'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment