Simplified, I want to do something like this:
({'publication': obj.pub_name, 'views': obj.views, } for obj = analyze_publication(p) for p in Publication.objects.all())
Of course, that doesn't work.
Right now, I'm using:
({'publication': obj.pub_name, 'views': obj.views, } for obj in (analyze_publication(p) for p in Publication.objects.all()))
I have no idea if the second code piece is how it's done or there's another syntax, or it's not efficient etc. I'm only 2 weeks into Python.
Just another version:
( dict(publication= obj.pub_name, views= obj.views)
for obj in map(analyze_publication, Publication.objects.all()) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With