[Tutor] Detect the folder of a file
Kanika Murarka
murarkakanika at gmail.com
Wed Apr 27 21:02:04 EDT 2016
Thanks Oliver and Alex, I didnt know about these commands :D
Oliver,
When i typed
print filename
print sys.executable
print sys.prefix
print os.path.split(sys.prefix)[-1]
my output was
/home/kanikaa/pydsa7/venv/lib/python2.7/site-packages/ipython_genutils/tests/test_tempdir.py
/usr/bin/python
/usr
usr
but i want to know weather file belongs to 'venv' folder or not.
Alex,
Yup, that was helpful, but I want to do it without activating the
environment.
Thanks Again
Kanika
On 27 April 2016 at 07:45, Alex Kleider <akleider at sonic.net> wrote:
>
>
> On 2016-04-26 16:16, Oliver Bestwalter wrote:
>
> sys.executable
>>>>>
>>>> '/home/obestwalter/.pyenv/versions/3.4.4/envs/tmp/bin/python3.4'
>>
>
> Not sure if this helps but perhaps:
>
> alex at X301:~/Py$ which python
> /usr/bin/python
> alex at X301:~/Py$ . venv/bin/activate
> (venv)alex at X301:~/Py$ which python
> /home/alex/Py/venv/bin/python
> (venv)alex at X301:~/Py$
>
> [Ubuntu 14.04 LTS]
>
>
More information about the Tutor
mailing list