[Tutor] Detect the folder of a file
Oliver Bestwalter
oliver at bestwalter.de
Tue Apr 26 19:16:47 EDT 2016
Hi,
>>> import sys
>>> sys.base_exec_prefix == sys.prefix
False
In a virtualenv those are different:
https://docs.python.org/3/library/sys.html#sys.base_exec_prefix
>>> sys.executable
'/home/obestwalter/.pyenv/versions/3.4.4/envs/tmp/bin/python3.4'
>>> sys.prefix
'/home/obestwalter/.pyenv/versions/3.4.4/envs/tmp'
This is the path to the virtualenv
>>> os.path.split(sys.prefix)[-1]
'tmp'
Gives you the name of the folder.
cheers
Oliver
On Wed, 27 Apr 2016 at 00:52 Danny Yoo <dyoo at hashcollision.org> wrote:
> On Tue, Apr 26, 2016 at 3:43 PM, Kanika Murarka <murarkakanika at gmail.com>
> wrote:
> > The folder which we create using command
> > $ Virtualenv venv
>
>
> Hi Kanika,
>
>
> I think you need to ask the virtualenv folks; it seems to be
> virtualenv-specific. Their forum is:
>
> https://groups.google.com/forum/#!forum/python-virtualenv
>
> Good luck!
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list