Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52410
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'one?': 0.05; 'convention,': 0.09; 'method,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'whole.': 0.09; 'python': 0.11; '2.7': 0.14; 'random': 0.14; 'posted': 0.15; 'kris': 0.16; 'reason.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'track.': 0.16; 'variables,': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'examples': 0.20; 'seems': 0.21; 'example': 0.22; 'import': 0.22; 'skip:+ 20': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'case.': 0.24; 'instance,': 0.24; 'looks': 0.24; 'sort': 0.25; 'nearly': 0.26; 'header:X -Complaints-To:1': 0.27; 'skip:+ 30': 0.30; 'work.': 0.31; 'code': 0.31; 'continues': 0.31; 'ordinary': 0.31; 'class': 0.32; 'there.': 0.32; 'could': 0.34; 'subject:with': 0.35; 'info': 0.35; 'classes': 0.35; 'but': 0.35; 'there': 0.35; 'replies': 0.36; 'right?': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'starting': 0.37; 'convention': 0.38; 'to:addr :python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'subject:back': 0.60; "you're": 0.61; "you'll": 0.62; 'kind': 0.63; 'refer': 0.63; 'subject:more': 0.64; 'more': 0.64; 'hoping': 0.75; 'yourself': 0.78; 'darn': 0.84; 'player.': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Dave Angel <davea@davea.name> |
| Subject | Re: back with more issues |
| Date | Mon, 12 Aug 2013 07:11:43 +0000 (UTC) |
| References | <cc701481-0ecd-411b-8473-0596b4252949@googlegroups.com> <mailman.493.1376286900.1251.python-list@python.org> <441b03e6-4280-4abf-9987-bb4aea81ae6d@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 174.32.174.30 |
| User-Agent | XPN/1.2.6 (Street Spirit ; Linux) |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.494.1376291526.1251.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1376291526 news.xs4all.nl 15979 [2001:888:2000:d::a6]:59036 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52410 |
Show key headers only | View raw
Kris Mesenbrink wrote: > darn i was hoping i could put off learning classes for a bit, but it seems that is not the case. i have tested it a bit and it seems to be working correctly now. > > ++++++++++++++++++++++++++++ > import random > > class player(): > hp = 10 > speed = 5 > attack = random.randint(0,5) > > print (player.attack) > > +++++++++++++++++++++++++++++++++++ > > i know it's not nearly as complicated as your examples but it seems to work. the self part of it always eluded me and continues to do so. and just so you know im learning through codecademy.com , it's based on python 2.7 and im trying to code in 3.3. but thanks for your help again and classes are starting (i think) to make some sort of sense.i'll have to reread both replies over and over again but it looks like a lot of useful info is there. but is the example i posted sorta right? i know i left the self part out but i think im on the right track. The "complication" was there for good reason. If you are sure you'll never have more than one player, this could work. i don't see the advantage over (ugh) global variables, however. But what happens when you have four monsters instead of one? A class provides you a way to store data for each instance, not just for the class as a whole. And the self convention is kind of analogous to the English "myself." If you're inside an ordinary method, you refer to yourself as "self." By the way, by convention, class names are capitalized. That's why i called it Player. -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
back with more issues Kris Mesenbrink <krismesenbrink@gmail.com> - 2013-08-11 20:33 -0700
Re: back with more issues Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-12 00:21 -0400
Re: back with more issues Kris Mesenbrink <krismesenbrink@gmail.com> - 2013-08-11 21:35 -0700
Re: back with more issues Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-12 00:51 -0400
Re: back with more issues Dave Angel <davea@davea.name> - 2013-08-12 05:54 +0000
Re: back with more issues Kris Mesenbrink <krismesenbrink@gmail.com> - 2013-08-11 23:31 -0700
Re: back with more issues Kris Mesenbrink <krismesenbrink@gmail.com> - 2013-08-11 23:57 -0700
Re: back with more issues Dave Angel <davea@davea.name> - 2013-08-12 07:11 +0000
Re: back with more issues Rotwang <sg552@hotmail.co.uk> - 2013-08-12 15:56 +0100
Re: back with more issues random832@fastmail.us - 2013-08-12 15:46 -0400
Re: back with more issues Kris Mesenbrink <krismesenbrink@gmail.com> - 2013-08-12 20:13 -0700
Re: back with more issues MRAB <python@mrabarnett.plus.com> - 2013-08-13 04:31 +0100
Re: back with more issues Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-12 23:48 -0400
Re: back with more issues Steven D'Aprano <steve@pearwood.info> - 2013-08-13 06:22 +0000
csiph-web