Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'true,': 0.05; '-1)': 0.09; 'false,': 0.09; 'cc:addr:python-list': 0.11; 'assume': 0.14; 'suggest': 0.14; '-1.': 0.16; 'bool': 0.16; 'false:': 0.16; 'here..': 0.16; '{true:': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'users.': 0.18; 'all,': 0.19; 'seems': 0.21; 'cc:addr:python.org': 0.22; 'initial': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'correct': 0.29; 'message-id:@mail.gmail.com': 0.30; 'anyone': 0.31; 'probably': 0.32; 'quite': 0.32; 'approval': 0.33; 'becomes': 0.33; "i'd": 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'depends': 0.38; 'simple,': 0.60; 'july': 0.63; 'total': 0.65; 'fact,': 0.69; 'bloody': 0.84; 'to:addr:ieee.org': 0.84; 'want:': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=NPT60KvbgTyrKFVGAeEOWTbZFWp0gDOe773pGmn4EBA=; b=n9L9pit9cK8p6aqeC3RAwVeXUJWwY6ShAN5rdATje5dhc1TRRlx0CrIz7pDyr+K7Y6 RVlRD7EPQAdkprgx3KDDccsNorMh8k67jmxgf1LJKqn0Rzje9FY5i8SRtOVvTdfJEDxv 91Uj4tgR2LhCAxBrB/IR4V4BLTd+iTaOZrdYwI7rpFG6eEyOINXMegL51va6GexmsdFM 2vuzT/hR9ayAA0jjCyVtmjJ3F4ztHnjLJeQM32R7IJhHdCHYflAtWgWe5ZomzoptqVX0 /VBRi1ETysgFkRpkSf5l1LWQ+BsVwH8A07Syt61rbbWE2iszF8HjcnNFCBYW0PK6LLGA nbjg== X-Received: by 10.152.45.65 with SMTP id k1mr5736598lam.78.1372802482216; Tue, 02 Jul 2013 15:01:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Joshua Landau Date: Tue, 2 Jul 2013 23:00:41 +0100 Subject: Re: how to calculate reputation To: Surya Kasturi Content-Type: text/plain; charset=UTF-8 Cc: python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372802489 news.xs4all.nl 15886 [2001:888:2000:d::a6]:52439 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49660 On 2 July 2013 22:43, Surya Kasturi wrote: > Hi all, this seems to be quite stupid question but I am "confused".. > We set the initial value to 0, +1 for up-vote and -1 for down-vote! nice. > > I have a list of bool values True, False (True for up vote, False for > down-vote).. submitted by users. > > [True, False, False, True....] > > Now to calculate the total reputation > > should I take True = +1, False=0 [or] True = +1, False=-1 ?? for adding > all. > > I am missing something here.. and that's clear.. anyone please help me on > it? It depends what you want to do. I suggest http://www.evanmiller.org/how-not-to-sort-by-average-rating.html. This aint so simple, but it's the correct way to sort by "approval". In fact, it's bloody confusing. To assume that only the "sum" approval counts, I'd not suggest {True: 1, False: 0}. The problem is that a "downvote" then becomes pointless. So probably go with False as -1. So you'd want: sum((1 if vote else -1) for vote in votes)