-Original Message- From: Walter Prins Sent: Feb 25, 2010 7:09 AM To: Dave Angel Cc: Alan Gauld , tutor@python.org Subject: Re: [Tutor] Strange list behaviour in classes
On 25 February 2010 11:22, Dave Angel <da...@ieee.org> wrote:
The indentation in your code is lost when I lo
On 25 February 2010 11:22, Dave Angel wrote:
> The indentation in your code is lost when I look for it -- everything's
> butted up against the left margin except for a single space before def
> variance. This makes it very hard to follow, so I've ignored the thread
> till now. This may be caus
James Reynolds wrote:
Thank you! I think I have working in the right direction. I have one more
question related to this module.
I had to move everything to a single module, but what I would like to do is
have this class in a file by itself so I can call this from other modules.
when it was in s
One point:
class Statistics:
def __init__(self, *value_list):
>self.value = value_list
>self.square_list= []
>def mean(self, *value_list):
>try :
>ave = sum(self.value) / len(self.value)
>except ZeroDivisionError:
>ave = 0
>return ave
You don't use value_list here you use self.value. So you don't
Thank you! I think I have working in the right direction. I have one more
question related to this module.
I had to move everything to a single module, but what I would like to do is
have this class in a file by itself so I can call this from other modules.
when it was in separate modules it ran w
"James Reynolds" wrote
I understand, but if self.value is any number other then 0, then the
"for"
will append to the square list, in which case square_list will always
have
some len greater than 0 when "value" is greater than 0?
And if value does equal zero?
Actually I'm confused by value
Thanks for the reply.
I understand, but if self.value is any number other then 0, then the "for"
will append to the square list, in which case square_list will always have
some len greater than 0 when "value" is greater than 0?
I'm just trying to understand the mechanics. I'm assuming that isn't
Forwarding to the list.
Please alweays use Reply All so others can comment too.
I made a few changes, but I'm getting the same error on variance (see below):
Looks like a different error to me!
It would seem to me that it should never evaluate if the denominator is zero
because of the if statem
"James Reynolds" wrote
This thread inspired me to start learning object oriented as well, but it
seems I must be missing something fundamental.
No, this has nothing to do with objects, its just a broken algorithm.
median = Statistics.stats.median(*a)
n = (self.value[m] + self.value[m
This thread inspired me to start learning object oriented as well, but it
seems I must be missing something fundamental. If I could get
an explanation of why I am raising the following exception, I would
greatly appreciate it.
I'm getting:
Traceback (most recent call last):
File "C:\Python31\Li
On 02/24/10 10:27, C M Caine wrote:
> Thanks all (again). I've read the classes tutorial in its entirety
> now, the problem I had didn't seem to have been mentioned at any point
> explicitly. I'm still a fairly inexperienced programmer, however, so
> maybe I missed something in there or maybe this
On 22 February 2010 23:28, Wayne Werner wrote:
> On Mon, Feb 22, 2010 at 4:10 PM, C M Caine wrote:
>>
>> Or possibly strange list of object behaviour
>>
>> IDLE 2.6.2
>> >>> class Player():
>> hand = []
>>
>>
>> >>> Colin = Player()
>> >>> Alex = Player()
>> >>>
>> >>> Players = [Colin, Al
On Mon, Feb 22, 2010 at 4:10 PM, C M Caine wrote:
> Or possibly strange list of object behaviour
>
> IDLE 2.6.2
> >>> class Player():
>hand = []
>
>
> >>> Colin = Player()
> >>> Alex = Player()
> >>>
> >>> Players = [Colin, Alex]
> >>>
> >>> def hands():
>for player in Players:
>
On 23 February 2010 08:16, Benno Lang wrote:
> class Hand:
> def __init__(self):
> self.hand = []
Of course, I meant "class Player"
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/m
On 23 February 2010 07:10, C M Caine wrote:
> Or possibly strange list of object behaviour
>
> IDLE 2.6.2
class Player():
> hand = []
>
>
Colin = Player()
Alex = Player()
Players = [Colin, Alex]
def hands():
> for player in Players:
>
15 matches
Mail list logo