On 9/7/06, Nate Straz <[EMAIL PROTECTED]> wrote:
> Wow, I never knew about that syntax. I checked the Language Reference
> all the way back to the 1.5 release and it is in every release. I'm
> surprised I've never seen that syntax used before.
>
> Thank you for pointing that out.
The reason yo
On Fri, Sep 08, 2006 at 03:18:22AM +0200, Daniel Poelzleithner wrote:
> in myapps/views.py:
> from .models import Somemodel
>
> which will import from myapps/models.py Somemodel
>
> from ..otherapp.models import Othermodel
>
> imports from myapps/../otherapp/models.py -> otherapps/models.py
>
Martin Glueck wrote:
> Be careful ... in one of the next releases of python, support for
> relative import will be dropped! So I would suggest that you don't
> rely on relative import in new written code and change it whenever you
> find it in old code.
It will not be droped in 2.5 but it will b
On Thu, 2006-09-07 at 03:41 +, SmileyChris wrote:
> When moving an app to a different project, I had to go through and fix
> all the references to my project name in code. Is there a better way to
> import my code? Currently I import like:
>
> from projectname.appname.models import Model
>
>
You don't need to physically move an app from project to project to use
the app in different projects. An app is just a python package. Say you
have app 'foo' from project 'bar' and you want to use it in a new
project, 'baz'. Install bar somewhere in your python path and then add
bar.foo to the IN
What about having a directory inside the project but also in the python
path for keeping shared applications. Then just code the applications
like
from appname.models import Model
and it's easy to move those applications between projects.
Regards,
Pedro
--~--~-~--~~---
> Well, as far as I know, python's import is relative. So if you're in the
> module /home/gray/white.py and you say
> import blue
> it will first try to find blue.py in /home/gray, so design your imports
> carefully.
Be careful ... in one of the next releases of python, support for
relativ
On Thu, 2006-09-07 at 03:41 +, SmileyChris wrote:
> When moving an app to a different project, I had to go through and fix
> all the references to my project name in code. Is there a better way to
> import my code? Currently I import like:
>
> from projectname.appname.models import Model
>
>
When moving an app to a different project, I had to go through and fix
all the references to my project name in code. Is there a better way to
import my code? Currently I import like:
from projectname.appname.models import Model
It seems like this inhibits portability of apps somewhat. Perhaps t