Re: [Tutor] Detect the folder of a file

2016-05-02 Thread Kanika Murarka
Thank you everyone ! My situation was to check the indentation of every python file via a script. I think looking for bin/activate will work. On 28 April 2016 at 23:08, Alan Gauld via Tutor wrote: > On 28/04/16 11:11, Steven D'Aprano wrote: > > > You know, some day I must

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Alan Gauld via Tutor
On 28/04/16 11:11, Steven D'Aprano wrote: > You know, some day I must learn why people use virtual environments. Me too :-) My co-author included a section in one of her chapters of our recent book, and I duly played with them while reviewing that chapter. But at the end I just deleted it all

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Joel Goldstick
On Thu, Apr 28, 2016 at 9:24 AM, Oscar Benjamin wrote: > On 28 April 2016 at 11:11, Steven D'Aprano wrote: >> On Thu, Apr 28, 2016 at 09:57:19AM +0100, Oscar Benjamin wrote: >> >> You know, some day I must learn why people use virtual

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Oscar Benjamin
On 28 April 2016 at 11:11, Steven D'Aprano wrote: > On Thu, Apr 28, 2016 at 09:57:19AM +0100, Oscar Benjamin wrote: > >> You can write some code to test if a particular path represents the >> base directory of a virtual environment but I expect it would probably >> be

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Steven D'Aprano
On Thu, Apr 28, 2016 at 09:57:19AM +0100, Oscar Benjamin wrote: > You can write some code to test if a particular path represents the > base directory of a virtual environment but I expect it would probably > be fragile. Without knowing why you want to do this I suggest that you > might want to

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Peter Otten
Oscar Benjamin wrote: > On 28 April 2016 at 02:02, Kanika Murarka wrote: >> Thanks Oliver and Alex, I didnt know about these commands :D >> >> Oliver, >> When i typed >> print filename >> print sys.executable >> print

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Oscar Benjamin
On 28 April 2016 at 02:02, Kanika Murarka wrote: > Thanks Oliver and Alex, I didnt know about these commands :D > > Oliver, > When i typed > print filename > print sys.executable > print sys.prefix > print

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Kanika Murarka
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

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Alex Kleider
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@X301:~/Py$ which python /usr/bin/python alex@X301:~/Py$ . venv/bin/activate (venv)alex@X301:~/Py$ which python

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Oliver Bestwalter
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

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Kanika Murarka
Thanks Danny On 27 Apr 2016 04:22, "Danny Yoo" wrote: > On Tue, Apr 26, 2016 at 3:43 PM, Kanika Murarka > wrote: > > The folder which we create using command > > $ Virtualenv venv > > > Hi Kanika, > > > I think you need to ask the virtualenv

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Kanika Murarka
The folder which we create using command $ Virtualenv venv On 27 Apr 2016 00:57, "Danny Yoo" wrote: On Tue, Apr 26, 2016 at 6:47 AM, Kanika Murarka wrote: > Hi, > I want to detect whether a 'file1.py' belongs to virtual environment > folder(

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Danny Yoo
On Tue, Apr 26, 2016 at 3:43 PM, Kanika Murarka 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:

Re: [Tutor] Detect the folder of a file

2016-04-26 Thread Danny Yoo
On Tue, Apr 26, 2016 at 6:47 AM, Kanika Murarka wrote: > Hi, > I want to detect whether a 'file1.py' belongs to virtual environment > folder( generally 'venv') or not ( considering different people may have > different names for virtual environment folder.). I think we

[Tutor] Detect the folder of a file

2016-04-26 Thread Kanika Murarka
Hi, I want to detect whether a 'file1.py' belongs to virtual environment folder( generally 'venv') or not ( considering different people may have different names for virtual environment folder.). I am able to detect it on my machine, but how to make it generalized. I am not getting anything on