Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81316

Re: I have no class

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <random832@fastmail.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; '---------': 0.07; 'attribute': 0.07; 'class,': 0.07; '22,': 0.09; 'received:internal': 0.09; 'def': 0.12; 'random': 0.14; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'subject:class': 0.16; 'tried:': 0.16; 'values?': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'import': 0.22; 'print': 0.22; 'header:In-Reply-To:1': 0.27; 'class': 0.32; 'skip:_ 10': 0.34; 'received:66': 0.35; 'skip:s 30': 0.35; 'received:10': 0.37; 'nov': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.63; 'different': 0.65; 'subject:have': 0.80; '2014,': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=PEzTdI8iIZDnN3OlK0P2Mrm+4Vw=; b=p9mh 8qGre8bABhihtn/NUreT+WuVbdR78BudzFEI6A3EU0GtK4qoJ6QeTsL+uT+RTMCQ a7m8u6b4gdey4D4ZiMswxauaEL4svcVp5CU9poSLwM+E50NYT7a2RIcHbavXOAaX aup+eZ7lFha/L+hQrm3NALJ6Hrtv8CdxfNs9/i8=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=PEzTdI8iIZDnN3OlK0P2Mrm+ 4Vw=; b=dUy/trUBV/xkWcGJhGQGfTnkyTrOKSlUEOQ/cgHl1yjwhpMRJrgRsURH vmAQykDge11ue8uYavs3ZxoRU5o4OEV/BgNmv+nK+etH7p6nXYHSEmpkzu+A34RI nCNoo3lyad8xYZTD3wQUmLI3OhN4EXUVfw1MQpz/70t7E7+sg6Q=
X-Sasl-Enc 1fvuuAdNJoxL/aPz1wXbBMootLvlGfQngrkmgZ+aVfKv 1416712111
From random832@fastmail.us
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-a419c8a0
In-Reply-To <e7h27ahs9rjaunu6d91opif62vbr2jefl9@4ax.com>
References <e7h27ahs9rjaunu6d91opif62vbr2jefl9@4ax.com>
Subject Re: I have no class
Date Sat, 22 Nov 2014 22:08:31 -0500
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16154.1416712114.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416712114 news.xs4all.nl 2894 [2001:888:2000:d::a6]:60283
X-Complaints-To abuse@xs4all.nl
X-Received-Body-CRC 742816976
X-Received-Bytes 4055
Xref csiph.com comp.lang.python:81316

Show key headers only | View raw



On Sat, Nov 22, 2014, at 21:47, Seymore4Head wrote:
> What do I need to do to make a and b have different values?
> import random
> class RPS:
>     throw=random.randrange(3)
> a=RPS
> b=RPS
> 
> print ("a ",a.throw)
> print ("b ",b.throw)
> if a.throw == b.throw:
>     print("Tie")
> elif (a.throw - b.throw)%3==1:    
>     print("a Wins")
> else:    
>     print("b Wins")  
> 
> ---------
> I tried:  
> 
> class RPS:
>     def __init__(self):
>         self.throw=random.randrange(3)
> 
> AttributeError: type object 'RPS' has no attribute 'throw'

You need that class, and also a=RPS(); b=RPS().

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 21:47 -0500
  Re: I have no class random832@fastmail.us - 2014-11-22 22:08 -0500
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:16 -0500
  Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-22 19:09 -0800
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:18 -0500
  Re: I have no class Ned Batchelder <ned@nedbatchelder.com> - 2014-11-22 22:14 -0500
    Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 22:35 -0500
      Re: I have no class Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-22 22:52 -0500
        Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 23:15 -0500
          Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-23 17:00 +1100
            Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 05:52 -0500
              Re: I have no class Dave Angel <davea@davea.name> - 2014-11-23 10:16 -0500
                Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 10:54 -0500
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-23 11:14 -0500
                Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-23 11:49 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 03:59 +1100
                Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-23 09:02 -0800
                Re: I have no class Steven D'Aprano <steve@pearwood.info> - 2014-11-24 04:21 +0000
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-24 00:11 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:11 +1100
                Re: I have no class Dan Sommers <dan@tombstonezero.net> - 2014-11-24 13:44 +0000
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-25 00:48 +1100
                Re: I have no class Dave Angel <davea@davea.name> - 2014-11-24 00:20 -0500
                Re: I have no class Chris Angelico <rosuav@gmail.com> - 2014-11-24 16:21 +1100
                Re: I have no class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-24 13:47 -0500
      Re: I have no class Rustom Mody <rustompmody@gmail.com> - 2014-11-22 19:55 -0800
        Re: I have no class Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-11-22 23:19 -0500
        Re: I have no class Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-23 15:35 +0000

csiph-web