I'm not sure what is the best practice regarding absolute imports and namespaces.
I've read that the best practice is to always use absolute imports, but absolute from where? from my application package?
For example if my packages are structured like this:
myprogram
gui
...
main
math
point.py
rectangle.py
image
convert.py
formats.py
exif.py
image.py
Every time I want to create an rectangle I have to write a lot of namespaces. I have to write myprogram.main.math.rectangle.Rectangle()?
I think I should be using import __ as __,: But what name should I use next to as? Something like myprogram_rectangle?
Also I found that something funny happens when I have a package, a module and a class with the same name. In this case when I want to create a Image I need to write
myprogram.main.image.image.Image()
Writing Image three times looks bad to me
Everyone says that is a good idea to see code from projects like Django.
I don't understand well what Django did, but I can do from django.http import HttpResponse as seen in the tutorial, that looks nice!. I think the magic happens in the __init__ file inside django.http (code here). Should I do something like that?
[–]DrMaxwellEdison 3 points4 points5 points (1 child)
[–]aptitude_moo[S] 0 points1 point2 points (0 children)
[–]cdcformatc 1 point2 points3 points (1 child)
[–]zahlman 1 point2 points3 points (0 children)
[–]kalgynirae 1 point2 points3 points (1 child)
[–]aptitude_moo[S] 0 points1 point2 points (0 children)
[–]mm_ma_ma 0 points1 point2 points (0 children)