Pure elegance:
print [self.entries[a] for a in range(len(self.entries)) if (viewingUser ==
self or not self.entries[a].isPrivate)]
and
print [entry for entry in self.entries if (viewingUser == self or not
entry.isPrivate)]
Built-in privacy on data model level. Live and learn. I love this language.
I want to thank Morn for the nice pun I used as title.
Update: Teh Mornster has flexed his mighty Python-Fu by showing me an easier way (second line). I remember starting out like this, but something didn’t work, so I tried another way (first line) which worked good. His idea is more elegant, tho. Thanks!
~ FIN ~
Carlo Zottmann is a Freelancing Web Developer from Munich, Germany. He is available for hire and can be reached via carlo@zottmann.org, Twitter, or Google+.