Interesting Problem

Victor Subervi victorsubervi at gmail.com
Wed Jan 20 12:06:05 EST 2010


On Wed, Jan 20, 2010 at 12:30 PM, Stephen Hansen <apt.shansen at gmail.com>wrote:

> On Wed, Jan 20, 2010 at 7:19 AM, Victor Subervi <victorsubervi at gmail.com>wrote:
>
>> Hi;
>> 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:
>>
>
> 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.
>
> 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.
>
> from myapp.templateFrame import top, bottom
> from myapp.some_directory.some_file import this, that
>
> etc.
>

I didn't know I could do that. Thanks!

>
>
>
>> Now, apparently because of python's problem with globals, when I call "id"
>> as follows:
>>
>>
> 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.
>

I didn't think that was a problem because it cascaded. Thanks, that fixed
it!
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100120/a6ba4ad8/attachment.html>


More information about the Python-list mailing list