<div class="gmail_quote">On Wed, Jan 20, 2010 at 12:30 PM, Stephen Hansen <span dir="ltr"><<a href="mailto:apt.shansen@gmail.com">apt.shansen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, Jan 20, 2010 at 7:19 AM, Victor Subervi <span dir="ltr"><<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote">
<div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi;<br>I think I finally have an interesting problem for y'all. I need to import a script from a lower dir, forcing me to change dirs:<br></blockquote><div><br></div></div><div>Don't do that. If you must, then the correct way to do it is to adjust your sys.path and not change directory. "sys.path.append('..')" or whatever.</div>
<div><br></div><div>But I really would just re-organize your code so you don't need such things. Have a single top-level directory that's on your path, put a blank __init__.py in all your directories, and use absolute imports everywhere.</div>
<div><br></div><div>from myapp.templateFrame import top, bottom</div><div>from myapp.some_directory.some_file import this, that</div><div><br></div><div>etc.</div></div></blockquote><div><br>I didn't know I could do that. Thanks! <br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div class="im"><div><br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Now, apparently because of python's problem with globals, when I call "id" as follows:<br><br></blockquote><div><br></div></div><div>Python does not have problems with globals. You are repeatedly re-using the same variable names, causing confusion and errors; when you say 'id' in that line of code, Python doesn't think you are talking about the "id" that is global. It thinks you are talking about the "id" that is local-- that you define one line beneath.</div>
</div></blockquote><div><br>I didn't think that was a problem because it cascaded. Thanks, that fixed it!<br>beno<br>
</div></div><br>