On 30/01/2014 12:39, loial wrote:
> I want to add a path to sys.path based upon a variable
>
> Can I do that?
>
> Hardcodeing the path works fine, but I want to set it based upon a
> variable.
>
> I know I can set PYTHONPATH, but just wondering if I can add a
> directory on the fly to sys.path using a variable
Certainly:
<code>
import sys
newpath = "c:/users/tim/modules"
sys.path.append(newpath)
</code>
TJG
> I want to add a path to sys.path based upon a variable
>
> Can I do that?
>
> Hardcodeing the path works fine, but I want to set it based upon a
> variable.
>
> I know I can set PYTHONPATH, but just wondering if I can add a
> directory on the fly to sys.path using a variable
Certainly:
<code>
import sys
newpath = "c:/users/tim/modules"
sys.path.append(newpath)
</code>
TJG
Aucun commentaire:
Enregistrer un commentaire