On Feb 16, 12:21 pm, galago <prog...@gmail.com> wrote: > My django runs on FastCGI as I can see. > I have that small part of the code: > > # Generate user register_hash > import hashlib > reg_hash = hashlib.md5() > reg_hash.update(request.POST.get('email') + > str(random.random()) + request.POST.get('username')) > reg_hash = reg_hash.hexdigest() > > Is there any sesne to load hashlib on the top? It's used once, when user is > created.
In this case I don't think it really matters much. If you want to be consistent with Python convention, you should put it at the top. In a case where the import is a single function or class, particularly if it's not a common one and/or used only once in the code, I personally might see more reason to import it where it's used. This would allow the reader to determine more easily where the object is defined without having to jump around in the code and also provides a pretty clear indication that the object isn't use elsewhere (assuming, of course that most imports are made at the top). -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.