organizing your scripts, with plenty of re-use
Stef Mientki
stef.mientki at gmail.com
Tue Oct 13 15:55:57 EDT 2009
>
> [snip]
>
>>> The key is to put all the core functionality into a package, and
>>> place the package where Python can find it. Also, it's a good idea
>>> to use relative imports from inside the package. There is no need to
>>> juggle with sys.path nor even set PYTHONPATH nor import __main__ nor
>>> play any strange games; it Just Works (tm).
>>>
>> please don't get angry,
>> I'm not a programmer, I'm just a human ;-)
>>
>> Hierarchical choices are done on todays knowledge, tomorrow we might
>> have different views and want/need to arrange things in another way.
>> An otter may become a reptile ;-)
>> So from the human viewpoint the following should be possible (and is
>> for example possible in Delphi)
>
>> - I can move the complete project anywhere I like and it should still
>> work without any modifications (when I move my desk I can still do my
>> work)
>
> Move a complete package anywhere along the PYTHONPATH and it will
> still work. Check.
>
>> - I can move any file in he project to any other place in the project
>> and again everything should work without any modifications ( when I
>> rearrange my books, I can still find a specific book)
>
> Move any file in any directory to any other spot in that same
> directory and it will still work. Check. ;-)
sub ;-)
>
> Humans are a lot smarter than computers. Even 'just humans'. ;-) If
> you move your book, then can't find it on the last shelf it used to be
> on, you look on other shelves, you look on your desk, you look on the
> coffe table, you look in your car, etc, etc, and so forth. If you
> move a file in a package to somewhere else, and you don't tell the
> package where it's at, it's not going to start looking all over the
> hard-drive for it.
I didn't say "whole the world";-)
> If that were the case you would have to be extra careful to have
> every module's name be distinct, and then what's the point of having
> packages?
Yes, I still wonder !
cheers,
Stef
>
> ~Ethan~
>
>> In my humble opinion if these actions are not possible, there must be
>> redundant information in the collection. The only valid reason for
>> redundant information is to perform self healing (or call it error
>> correction), and here we have a catch-22.
>>
>> cheers,
>> Stef Mientki
>
More information about the Python-list
mailing list