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
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.
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
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
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
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
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
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
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
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:
>
>
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
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 '
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
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
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
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.
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
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?
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
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)
>>>
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
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
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)
>>
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:
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
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
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")
-
27 matches
Mail list logo