Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81323
| 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!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| 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; '---------': 0.07; 'attribute': 0.07; '22,': 0.09; 'broke': 0.09; 'cc:addr:python- list': 0.11; 'def': 0.12; 'random': 0.14; '>>on': 0.16; 'dictionary,': 0.16; 'object).': 0.16; 'output?': 0.16; 'subject:class': 0.16; 'tried:': 0.16; 'values?': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'too.': 0.31; 'class': 0.32; 'url:python': 0.33; 'skip:_ 10': 0.34; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'object,': 0.36; 'skip:> 10': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'should': 0.36; 'nov': 0.38; 'pm,': 0.38; 'url:mail': 0.40; 'how': 0.40; 'simply': 0.61; 'show': 0.63; 'different': 0.65; 'skip:1 20': 0.65; 'subject:have': 0.80; 'batchelder': 0.84; 'want:': 0.84; 'joel': 0.91; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=sOCkZszZ3weN9aV9/H5rG4hgAKgvnL2eRa6lR51fq08=; b=Aze4s+pa2+RPumczcoYM/4Ho9GeI8M+4Qgr2wnA+6IMOByn3U+1AvRyflIVccK3xC7 eIaOLOFNB9wUqmYxB3+QTr1Il+nqJyVstG5lxjiJY7q8DczNL5nowQKsl4E2dinNrVxL sYvj29c2NbC+FM1GHvJL762YuAK9PdmEXMLI2nowLb4dph+CTPnrY9CUO1vQz0WUtrzq etIlc+aLrBeo5DENdIKmCHWe2Vkv43CA4ocRfWLaC4CJr14aiDb8zAKsSTvo+YZIF+wM DiF8wLcNBoKnKsuBm7pELLoV/LyLvl6Ehx6dZApuJBBzT3U6Pz40xrGelw8r8dNPW5j3 bHbg== |
| MIME-Version | 1.0 |
| X-Received | by 10.224.4.197 with SMTP id 5mr19317312qas.74.1416714753212; Sat, 22 Nov 2014 19:52:33 -0800 (PST) |
| In-Reply-To | <l9l27alml8scm4dvf29m2vidcudhh6766o@4ax.com> |
| References | <e7h27ahs9rjaunu6d91opif62vbr2jefl9@4ax.com> <mailman.16156.1416712474.18130.python-list@python.org> <l9l27alml8scm4dvf29m2vidcudhh6766o@4ax.com> |
| Date | Sat, 22 Nov 2014 22:52:33 -0500 |
| Subject | Re: I have no class |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.16157.1416714761.18130.python-list@python.org> (permalink) |
| Lines | 57 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1416714761 news.xs4all.nl 2906 [2001:888:2000:d::a6]:50902 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Body-CRC | 802857200 |
| X-Received-Bytes | 4950 |
| Xref | csiph.com comp.lang.python:81323 |
Show key headers only | View raw
On Sat, Nov 22, 2014 at 10:35 PM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
> On Sat, 22 Nov 2014 22:14:21 -0500, Ned Batchelder
> <ned@nedbatchelder.com> wrote:
>
>>On 11/22/14 9:47 PM, 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
>>
>>This simply makes a and b into other names for the class RPS. To
>>instantiate a class to make an object, you have to call it:
>>
>> a = RPS()
>> b = RPS()
>>
>>> ---------
>>> I tried:
>>>
>>> class RPS:
>>> def __init__(self):
>>> self.throw=random.randrange(3)
>>>
>>> AttributeError: type object 'RPS' has no attribute 'throw'
>>
>>This is the right way to define the class (almost: in Py 2, you should
>>derive from object). Once you make an object from it, you will have what
>>you want:
>>
>> class RPS(object):
>> def __init__(self):
>> self.throw = random.randrange(3)
>>
>> a = RPS()
>> b = RPS()
>> print a.throw
>> print b.throw
>
> Now I am trying to add a dictionary, but it is broke too.
>
> How do I fix:
> class RPS:
> key={0:"rock", 1:"paper",2:"scissors"};
> def __init__(self):
> self.throw=random.randrange(3)
> self.key=key[self.throw]
> --
> https://mail.python.org/mailman/listinfo/python-list
can you please show traceback and output?
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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