Re: I have no class

2014-11-24 Thread Chris Angelico
On Tue, Nov 25, 2014 at 12:44 AM, Dan Sommers wrote: > And then, at least in C++, you see coding standards that demand that > member variables (aka instance variables aka attributes) be named in > such a way that you can tell that they're member variables and not local > variables (one common conv

Re: I have no class

2014-11-24 Thread Dan Sommers
On Mon, 24 Nov 2014 16:11:32 +1100, Chris Angelico wrote: > On Mon, Nov 24, 2014 at 3:21 PM, Steven D'Aprano wrote: >> On Sun, 23 Nov 2014 09:02:57 -0800, Rustom Mody wrote: >> >>> Python is a bit odd in the OO-world in that it prioritizes "Explicit is >>> better than implicit" over convenience.

Re: I have no class

2014-11-23 Thread Dave Angel
On 11/24/2014 12:11 AM, Dave Angel wrote: On 11/23/2014 11:21 PM, Steven D'Aprano wrote: In some of these languages, the use of "this/self/me" is optional, but I'm not aware of *any* OOP language where there is no named reference to the current object at all. The case I found astounding in C

Re: I have no class

2014-11-23 Thread Chris Angelico
On Mon, Nov 24, 2014 at 4:11 PM, Dave Angel wrote: > The case I found astounding in C++ was in the initializer list where the > line > > value:value > > would assume that the first one was this->value, and the second was a local > named value (usually an argument to the constructor). That's

Re: I have no class

2014-11-23 Thread Dave Angel
On 11/23/2014 11:21 PM, Steven D'Aprano wrote: In some of these languages, the use of "this/self/me" is optional, but I'm not aware of *any* OOP language where there is no named reference to the current object at all. The case I found astounding in C++ was in the initializer list where the l

Re: I have no class

2014-11-23 Thread Chris Angelico
On Mon, Nov 24, 2014 at 3:21 PM, Steven D'Aprano wrote: > On Sun, 23 Nov 2014 09:02:57 -0800, Rustom Mody wrote: > >> Python is a bit odd in the OO-world in that it prioritizes "Explicit is >> better than implicit" over convenience. >> >> Notice that you use self.throw where in most other OOP lang

Re: I have no class

2014-11-23 Thread Steven D'Aprano
On Sun, 23 Nov 2014 09:02:57 -0800, Rustom Mody wrote: > Python is a bit odd in the OO-world in that it prioritizes "Explicit is > better than implicit" over convenience. > > Notice that you use self.throw where in most other OOP languages you > would use just throw. I don't think that is correc

Re: I have no class

2014-11-23 Thread Rustom Mody
On Sunday, November 23, 2014 10:20:05 PM UTC+5:30, Seymore4Head wrote: > Like I have said, most of the stuff I am doing is still trial and > error. Having to specify RPS to use it inside the class seemed wrong > to me. Yes that is natural. Python is a bit odd in the OO-world in that it prioritize

Re: I have no class

2014-11-23 Thread Chris Angelico
On Mon, Nov 24, 2014 at 3:49 AM, Seymore4Head wrote: > Like I have said, most of the stuff I am doing is still trial and > error. Having to specify RPS to use it inside the class seemed wrong > to me. > > I haven't read enough about classes yet to know what the correct way > is yet. That's becau

Re: I have no class

2014-11-23 Thread Seymore4Head
On Sun, 23 Nov 2014 11:14:34 -0500, Dave Angel wrote: >On 11/23/2014 10:54 AM, Seymore4Head wrote: >> On Sun, 23 Nov 2014 10:16:28 -0500, Dave Angel >> wrote: >> >>> On 11/23/2014 05:52 AM, Seymore4Head wrote: On Sun, 23 Nov 2014 17:00:08 +1100, Chris Angelico wrote: > >

Re: I have no class

2014-11-23 Thread Dave Angel
On 11/23/2014 10:54 AM, Seymore4Head wrote: On Sun, 23 Nov 2014 10:16:28 -0500, Dave Angel wrote: On 11/23/2014 05:52 AM, Seymore4Head wrote: On Sun, 23 Nov 2014 17:00:08 +1100, Chris Angelico wrote: 1) Python's namespacing rules mean that 'key' is a part of the RPS class, and can be refe

Re: I have no class

2014-11-23 Thread Seymore4Head
On Sun, 23 Nov 2014 10:16:28 -0500, Dave Angel wrote: >On 11/23/2014 05:52 AM, Seymore4Head wrote: >> On Sun, 23 Nov 2014 17:00:08 +1100, Chris Angelico >> wrote: >> >>> >>> 1) Python's namespacing rules mean that 'key' is a part of the RPS >>> class, and can be referred to as 'self.key' or as '

Re: I have no class

2014-11-23 Thread Mark Lawrence
On 23/11/2014 03:55, Rustom Mody wrote: On Sunday, November 23, 2014 9:06:03 AM UTC+5:30, Seymore4Head wrote: 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.randr

Re: I have no class

2014-11-23 Thread Dave Angel
On 11/23/2014 05:52 AM, Seymore4Head wrote: On Sun, 23 Nov 2014 17:00:08 +1100, Chris Angelico wrote: 1) Python's namespacing rules mean that 'key' is a part of the RPS class, and can be referred to as 'self.key' or as 'RPS.key' 2) Use of 'self.key' for the textual form of the throw is shadow

Re: I have no class

2014-11-23 Thread Seymore4Head
On Sun, 23 Nov 2014 17:00:08 +1100, Chris Angelico wrote: >On Sun, Nov 23, 2014 at 3:15 PM, Seymore4Head > wrote: >> Traceback (most recent call last): >> File "C:\Documents and Settings\Administrator\Desktop\rps.py", line >> 7, in >> a=RPS() >> File "C:\Documents and Settings\Administra

Re: I have no class

2014-11-22 Thread Chris Angelico
On Sun, Nov 23, 2014 at 3:15 PM, Seymore4Head wrote: > Traceback (most recent call last): > File "C:\Documents and Settings\Administrator\Desktop\rps.py", line > 7, in > a=RPS() > File "C:\Documents and Settings\Administrator\Desktop\rps.py", line > 6, in __init__ > self.key=key[self.

Re: I have no class

2014-11-22 Thread Seymore4Head
On Sat, 22 Nov 2014 19:55:08 -0800 (PST), Rustom Mody wrote: >On Sunday, November 23, 2014 9:06:03 AM UTC+5:30, Seymore4Head wrote: >> 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__(se

Re: I have no class

2014-11-22 Thread Seymore4Head
On Sat, 22 Nov 2014 22:52:33 -0500, Joel Goldstick wrote: >On Sat, Nov 22, 2014 at 10:35 PM, Seymore4Head > wrote: >> On Sat, 22 Nov 2014 22:14:21 -0500, Ned Batchelder >> wrote: >> >>>On 11/22/14 9:47 PM, Seymore4Head wrote: What do I need to do to make a and b have different values?

Re: I have no class

2014-11-22 Thread Rustom Mody
On Sunday, November 23, 2014 9:06:03 AM UTC+5:30, Seymore4Head wrote: > 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[s

Re: I have no class

2014-11-22 Thread Joel Goldstick
On Sat, Nov 22, 2014 at 10:35 PM, Seymore4Head wrote: > On Sat, 22 Nov 2014 22:14:21 -0500, Ned Batchelder > 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) >>>

Re: I have no class

2014-11-22 Thread Seymore4Head
On Sat, 22 Nov 2014 22:14:21 -0500, Ned Batchelder 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 t

Re: I have no class

2014-11-22 Thread Seymore4Head
On Sat, 22 Nov 2014 19:09:27 -0800 (PST), Rustom Mody wrote: >On Sunday, November 23, 2014 8:17:24 AM UTC+5:30, 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

Re: I have no class

2014-11-22 Thread Seymore4Head
On Sat, 22 Nov 2014 22:08:31 -0500, random...@fastmail.us wrote: > > >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) >>

Re: I have no class

2014-11-22 Thread Ned Batchelder
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:

Re: I have no class

2014-11-22 Thread Rustom Mody
On Sunday, November 23, 2014 8:17:24 AM UTC+5:30, 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

Re: I have no class

2014-11-22 Thread random832
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.thr

I have no class

2014-11-22 Thread Seymore4Head
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") -