<div dir="ltr">it tell the path upto the python file..<br><br><div class="gmail_quote">On Fri, Feb 5, 2010 at 5:43 PM, Spoorthi <span dir="ltr">&lt;<a href="http://spoorthi.ms">spoorthi.ms</a>@<a href="http://gmail.com">gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The below data(in blue) made me converge upon sys.path[0] for this particular problem...I dont think it returns None if a Python script is used. Can anyone please correct me if I am wrong<br>
<br><i style="color: rgb(51, 102, 255);">As initialized upon program startup, the first item of this list,
<code>path[0]</code>, is the directory containing the script that was used to
invoke the Python interpreter. If the script directory is not
available (e.g. if the interpreter is invoked interactively or if the
script is read from standard input), <code>path[0]</code> is the empty string,
which directs Python to search modules in the current directory
first. Notice that the script directory is inserted <i>before</i> the
entries inserted as a result of PYTHONPATH.</i><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Fri, Feb 5, 2010 at 5:38 PM, Rohit Roger$ <span dir="ltr">&lt;<a href="mailto:rohitraj007@gmail.com" target="_blank">rohitraj007@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><br>sys.path[0] returns none<div><div></div><div><br><br><br><div class="gmail_quote">

On Fri, Feb 5, 2010 at 5:36 PM, Spoorthi <span dir="ltr">&lt;<a href="http://spoorthi.ms" target="_blank">spoorthi.ms</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">sys.path[0] should be serving the purpose effectively I guess<div><div></div><div>
<br><br><div class="gmail_quote">On Fri, Feb 5, 2010 at 5:29 PM, Rohit Roger$ <span dir="ltr">&lt;<a href="mailto:rohitraj007@gmail.com" target="_blank">rohitraj007@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr">Answer :<br> &gt;&gt;&gt; import sys<br>&gt;&gt;&gt; rohit = sys.argv[0]<br>


&gt;&gt;&gt; print rohit<br>
 it returns the name of the path<br><br><div class="gmail_quote">On Fri, Feb 5, 2010 at 4:13 PM, David Hutto <span dir="ltr">&lt;<a href="mailto:dwightdhutto@yahoo.com" target="_blank">dwightdhutto@yahoo.com</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div style="font-size: 12px; color: rgb(153, 153, 153); font-family: &#39;Lucida Grande&#39;,Helvetica,Arial,sans-serif;">

Junk Score: 2 out of 10 (below <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/mail-screening" target="_blank">your Auto Allow threshold</a>)
| <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/anno?tc=1529381613_418589136" target="_blank">Approve sender</a> | <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/anno?tc=1529381613_418589136&amp;disp=b" target="_blank">Block sender</a> | <a style="text-decoration: none; color: rgb(94, 150, 234);" href="https://www.boxbe.com/anno?tc=1529381613_418589136&amp;disp=b&amp;dom" target="_blank">Block domain</a>


  
  <img src="" style="margin-left: 5px;" width="10"><img src=""><br>
</div><br><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">




<br><br>--- On <b>Fri, 2/5/10, nikunj badjatya <i>&lt;<a href="mailto:nikunjbadjatya@gmail.com" target="_blank">nikunjbadjatya@gmail.com</a>&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">




<br>From: nikunj badjatya &lt;<a href="mailto:nikunjbadjatya@gmail.com" target="_blank">nikunjbadjatya@gmail.com</a>&gt;<br>Subject: [Tutor] python function to know the path of the program in execution<br>To: <a href="mailto:tutor@python.org" target="_blank">tutor@python.org</a><br>




Date: Friday, February 5, 2010, 5:08 AM<br><br><div>Hi ,<br>Is there any python function to know the path of the python program under execution.?<br>If someone executes a program , he should come to know the path of the program..!!<br>




ex. suppose a user ABC is running prog.py which is in ~ directory, the user currently is in XYZ directory. <br>

[ ABC@localhost XYZ ]$ python ~/prog.py         <br>The program&#39;s location is ~/prog.py<br><br>This should be the outcome of the program.<br><br>I tried with os.getcwd()<br clear="all">os.getcwd() will return /path/to/folder/XYZ.<br>






<br>Any suggestions?<br> <br>Thanks,<br>Nikunj Badjatya<br>Bangalore, India<br>
</div><br>-----Inline Attachment Follows-----<br><br><div>_______________________________________________<br>Tutor maillist  -  <a href="http://mc/compose?to=Tutor@python.org" target="_blank">Tutor@python.org</a><br>To unsubscribe or change subscription options:<br>




<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br><br><br>I think this is what you want:<br><br>&gt;&gt;&gt; import sys<br>&gt;&gt;&gt; sys.argv[0]<br>




&#39;C:\\Python26\\testingscripts\\lowdir.py&#39;<br>&gt;&gt;&gt; <br><br>David<br></div></blockquote></td></tr></tbody></table><br>



      <br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br><br clear="all"><br></div></div>-- <br><font color="#888888">Spoorthi <br>
</font></blockquote></div><br></div></div></div>
</blockquote></div><br><br clear="all"><br></div></div>-- <br><font color="#888888">Spoorthi <br>
</font></blockquote></div><br></div>