This is something I've found confusing ever since my first contact with django, reading the tutorial - all this emphasis on apps being portable and decoupled from the project where it is used. But doesn't the project being the top level python package make it almost impossible to move an app from a project to another without modifying the import statements? Yes it's true that you can use relative imports but if I remember correctly that only works within a package so if your app contains any sub packages it still won't help you, or am I missing something here?
The new style imports of PEP 238 seem to remove this limitation though, if you're using python 2.5+. On 12 Apr, 13:52, webograph <[EMAIL PROTECTED]> wrote: > hi, > > as i read that pep, relative imports are not deprecated at all, they > just will require a new syntax in 2.8. > i advocate the use of relative imports, in cases like newforms as well > as in "user-space" apps, due to the possibility of name changes: sooner > or later, newforms will just be called forms; an import statement like > > >>> from . import util > > (syntax according to pep 0328; note i'd even leave out the newforms > part) has the advantage of being stable across module re-naming as well > as being unambiguous; thus, i'd leave the imports as they are, changing > to the new syntax as soon as python-2.4 support is dropped. > > same goes for "user-space" apps, by the way: in the tutorial (3), it is > recommended to use a syntax like > > >>> from mysite.polls.models import Poll > > which causes problems if mysite is renamed or, more likely, the polls > app is re-used on another site. > > regards > webograph --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---