Задать вопрос

Тел: +7 965 3737 888

456

Просмотров

3

Ответов

Updated version of #31

<p>This is, I think, a slightly cleaner implentation of what <a href="https://djangosnippets.org/snippets/31/">snippet 31</a> is trying to do; by starting off with a dictionary containing the things we want to look for, and using a list comprehension to kill anything which comes out of the form as None, we can avoid some of the intermediate data structures the other snippet was using, and hopefully get better performance.</p>
<p>This is also quite a bit more maintainable, because supporting additional options now only requires adding a new key/value pair to qdict.</p>

Вопрос полезен? Да0/Нет0
file_3669.py(848.0б)
None

Ответы (3):

Ответlbolognini:13.03.2007
Ответ полезен? Да0/Нет0

Very nice James, thanks!

Ответubernostrum:12.03.2007
Ответ полезен? Да0/Нет0

Just updated it with the way I should have written it in the first place, using dictionary unpacking to handle the keyword arguments to Q. It introduces quite a few more dictionary instantiations, but still keeps the maintainability of the original.

Ответlbolognini:03.03.2007
Ответ полезен? Да0/Нет0

Hi James,

thanks for doing this, only thing is that in q_objs Q can't be an expression. I'll be posting a rather more verbose version of my first snippet soon... sylistic improvements/corrections/suggestions still very welcome!

Ciao, Lorenzo