Amandeep Behl wrote:

> Can anyone explain this code below:
>
>
>
> <div dir="ltr"><div>Can anyone explain this code 
> below:</div><div><br></div><br><div><div>import sys</div><div>import 
> os</div><div>                              </div><div>if __name__ == 
> &#39;__main__&#39;:  </div><div>    sys.path.insert(0, &quot;..&quot;) </div>
> <div>else:                        </div><div>    sys.path.insert(0, 
> os.path.join(</div><div>        os.path.split(__file__)[0], 
> &#39;..&#39;))</div></div></div>
>

Yes, the gobbledygook is caused by selecting html email, rather than the
needed text form.

As for the code that's buried inside there, it seems to have no
usefulness if the file is run directly as a script, but if it's imported
from another script, it adds a particular directory to the search path.

Subsequent imports may find imports in that directory.

-- 
DaveA


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to