Looks like I'm golden in this regard. My first path element is '' which is what I'd want if I'm including a modified library.
Thank you, On Thu, Sep 20, 2018 at 6:14 PM, Mats Wichmann <m...@wichmann.us> wrote: > On 09/19/2018 09:59 PM, Chip Wachob wrote: >> Mats, >> >> Silly question here.. >> >> But after using the git clone command, I've got a directory of the >> Adafruit project in the same directory as my project. >> >> When I import the library, will I get the 'installed' library, or do I >> get the library that is in the project directory? >> >> If I have to specify which library to use, how is that done? > > you look at, and possibly modify, sys.path > > > >>> import sys > >>> sys.path > ['', '/usr/lib64/python36.zip', '/usr/lib64/python3.6', > '/usr/lib64/python3.6/lib-dynload', > '/usr/lib64/python3.6/site-packages', '/usr/lib/python3.6/site-packages'] > > > the first element '' is the local directory, so with my sys.path, it > would pick the local one first. > > > if you wanted the opposite, that is be _sure_ you get the installed one, > you could use a stanza something like this: > > > savepath = sys.path > sys.path = [path for path in sys.path if path.strip('.')] > import foo > sys.path = savepath > > > but this is actually kind of tricky stuff, trying to deal with possibly > two modules of the same name, so tread carefully. > > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor