News for hackers. Stuff that matters.
Re:Python Best Practice Patterns by edavis on Friday February 28, 2014 @03:07PM (#7321118)
May I suggest `any` here?

    def is_file_for(is_nagyker, type):
        return any([
            type == KIS_ES_NAGYKER,
            type == KISKER and not is_nagyker,
            type == NAGYKER and is_nagyker])
I know unsolicited code improvements from strangers isn't the coolest thing in the world, but `any` (and `all`) can really improve clarity for stuff like this. I know I use them quite a bit.
Re:Python Best Practice Patterns by aidos on Friday February 28, 2014 @06:10PM (#7322166)
I saw that used in the article too - not something I'd thought to do myself. Thanks for pointing it out, I find it really readable and I know there are places I could use this.
Re:Python Best Practice Patterns by shoyer on Saturday March 01, 2014 @12:21PM (#7325121)
You create a list, so this expression won't shortcut like or. Or is definitely the right way to write an expression like this. Any has its place, but mostly when it's input is a generator, e.g.,

    any(k in obj for k in other)