from Python import love

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!

posted 5 years ago in Code en Hacking Python

About this site and its Author

  • czottmann
The personal blog of Carlo Zottmann, a freelance software developer from Munich, Germany.

He builds "applications" or "sites" for them so-called "internets". Currently notable projects are TwerpScan and Ephemera, a Mac tool for Instapaper enthusiasts with ebook readers.

His hobbies include taming dolphins, riding lemurs and collecting spores, molds and fungus — the food of the future.