"import models" vs. "from models import *": There might be some low-level nuance differences, but the important one (to me) is your module's name space.
If you do "from blah import *" you wind up with everything in the other module. This *may* be what you want, but it usually isn't. If there's something in that module with the same name as the one doing the importing, it can lead to bugs that are really hard to track down. You also throw away any clues about where something's defined. More and more, I find myself doing things like "import modules.MyCompany.StringUtilities.foo as foo" because it's a lot easier to write foo.whatever than specifying the entire namespace, but I'm still using names that are distinctive enough that I don't have to worry about where something came from. (You can do that by adding directories modules/MyCompany/ StringUtilities and then a module named foo.py. Put a file named __init.py__ in each directory in the tree. I know you can do cool things with that file...probably to specify actions that happen before any modules in that directory or subdirectories get loaded, but I've never really cared enough to look into it). AFAICT, it's just a matter of style and preference (and how much effort is some given thing worth). But it's been my experience that from blah import * is just begging for trouble. (from blah import specific is much better). Regards, James On Dec 11, 6:38 pm, djidjadji <djidja...@gmail.com> wrote: > For point 1) > > Place the model class definitions in 1 or more separate .py files > You can put more then 1 model class in a .py file when you use the > multiple file approach > > eq. models.py # all model classes in one file > > or user.py > forum.py > comment.py > > And use import statements like > > from models import * > > or > > from user import * > from comment import * > > in the model files that need other model definitions and in the .py > files that handle the requests (the ones named in the app.yaml file) > > Some people use > > import models > > and they have to use > > customer = models.User(......) > > instead of > > customer = User(......) > > At Python interpreter level it must have a different result, but I > have no problem using the "from import *" method > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---