Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64990
| Date | 2014-01-30 12:42 +0000 |
|---|---|
| From | Tim Golden <mail@timgolden.me.uk> |
| Subject | Re: Add directory to sys.path based on variable |
| References | <08cb4673-c926-487e-a101-299ed899239a@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6128.1391085772.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Add directory to sys.path based on variable loial <jldunn2000@gmail.com> - 2014-01-30 04:39 -0800
Re: Add directory to sys.path based on variable Tim Golden <mail@timgolden.me.uk> - 2014-01-30 12:42 +0000
Re: Add directory to sys.path based on variable loial <jldunn2000@gmail.com> - 2014-01-30 06:03 -0800
Re: Add directory to sys.path based on variable Chris Angelico <rosuav@gmail.com> - 2014-01-31 01:09 +1100
Re: Add directory to sys.path based on variable Tim Golden <mail@timgolden.me.uk> - 2014-01-30 14:14 +0000
Re: Add directory to sys.path based on variable loial <jldunn2000@gmail.com> - 2014-01-30 06:26 -0800
csiph-web