Re: [Tutor] understanding __import__()

2006-07-26 Thread Sean Perry
Kent Johnson wrote: > The first argument to __import__ should be a module or package name, not > a file path, e.g. "my.settings". Python will look for the module in the > current sys.path the same as if you used a normal import. Apparently the > / is being interpreted as a . and I guess you have

Re: [Tutor] understanding __import__()

2006-07-26 Thread Kent Johnson
Sean Perry wrote: > Ok, this may be slightly above tutor's level, but hey, never hurts to > ask (-: > > I am playing with __import__(). Here is my code: > [code] > import os.path > > app_path = '/tmp/my/settings' > app_path2 = 'my/settings' > > if os.path.exists(app_path + '.py'): > print "F

Re: [Tutor] understanding __import__()

2006-07-25 Thread python-tutor
Sean Perry wrote: > Ok, this may be slightly above tutor's level, but hey, never hurts to > ask (-: __import__ is dark magic; generally those who venture into that realm would do well to read the C source for Python.. I'm guessing that '.' is not in your sys.path, so Python isn't finding the rel

[Tutor] understanding __import__()

2006-07-25 Thread Sean Perry
Ok, this may be slightly above tutor's level, but hey, never hurts to ask (-: I am playing with __import__(). Here is my code: [code] import os.path app_path = '/tmp/my/settings' app_path2 = 'my/settings' if os.path.exists(app_path + '.py'): print "Found", app_path try: f = __import