I have seen some views of the Python list before, but can this be done on a single line in Python?
errs = {} for f in form: if f.errors: errs[f.auto_id] = f.errors
errs = dict((f.auto_id, f.errors) for f in form if f.errors)
Python 3.0 has a clear understanding of the shorter / more readable form of anser provided by Steef:
errs = {f.auto_id: f.errors for f in form if f.errors}
, , " ". (PEP 20), , .:)
, " , ". " ", , :)
, . . :)
Source: https://habr.com/ru/post/1710461/More articles:How to declare a method in C ++ / CLI that will be considered as an extension method in C #? - c #TFS: merge changes from one file back to the latest version - tfsПростая проблема AS2 - actionscript-2using jquery elements to group - jqueryOracle extractValue does not work when a query returns many rows - sqlCurrency of Great Britain. Regular expression for javascript - javascriptHow to compile Botan crypton library as a static library in VC ++? - c ++The best strategy for calling an arbitrary function without using JMP or LCALL - cMethod code in C # serialization - c #Как связать статическую библиотеку в Visual С++ 2008? - c++All Articles