Alan Isaac <[EMAIL PROTECTED]> wrote: > > "Alex Martelli" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > I don't know of any "pretty" way -- I'd do it by path manipulation > > > (finding mypackage from os.path.abspath(__file__) and inserting its > > > _parent_ directory in sys.path). > > > > "Alan Isaac" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Yes, that seems to be the standard solution. > > I find it ugly. > > Just to confirm that I am right to find it ugly: > does this not clearly introduce the possibility of name clashes? > Or am I overlooking some trick?
If you use sys.path.insert(0, ...), not sys.path.append, I'm not sure what "name clashes" you're thinking of -- as long as you avoid naming your modules the same as ones in the standard library (which is a good practice I heartily recommend), of course, what scenario do you fear? You can have more control about _where_ stuff can get imported from by directly calling the __import__ builtin, but that's not often needed. Alex -- http://mail.python.org/mailman/listinfo/python-list