Thanks for the advice. As is often the case with these things, eryksun
pointed out a stupid mistake I'd made (mutating part of an immutable class)
that I should have seen.
On 6 December 2012 00:50, Oscar Benjamin wrote:
> On 5 December 2012 18:11, C M Caine wrote:
> > Dear all
hem accident or
stupidity later.
On 6 December 2012 01:31, eryksun wrote:
> On Wed, Dec 5, 2012 at 1:11 PM, C M Caine wrote:
> >
> > The full code is on pastebin http://pastebin.com/tUh0W5Se
> >
> >>>> import game
> >>>> S = game.State()
> &g
I edited the output of Lines 109-111 from my source code out of the
interpreter transcripts above, by the by.
On 5 December 2012 18:11, C M Caine wrote:
> Dear all,
>
> I've written a class State that subclasses tuple. The class has a method
> move_state that takes a move
Dear all,
I've written a class State that subclasses tuple. The class has a method
move_state that takes a move and returns a new state object representing
the new state of the game.
I would expect S1 and S3 to be equal on the last line here, but they are
not.
>>> import game
>>> S = game.State(
On 24 May 2010 09:20, Matthew Wood wrote:
> Well, I'd use the raw_input function instead of the input function.
>
> and I'd check out the math.floor function as well. :-)
>
> Lemme know if you have any other questions.
>
> --
>
> I enjoy haiku
> but sometimes they don't make sense;
> refrigerator
Thank you all. One tangentially related question: what does (self,
*args, **kwargs) actually mean? How does one reference variables given
to a function that accepts these inputs?
Colin
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subs
I'm writing a class that inherits the inbuilt dict class and want some
of my own code to run at initialisation, on the other hand, I still
want the original dict.__init__ function to run. Can I ask the class
to run the original __init__ and then my own function at
initialisation automatically? If s
On 26 April 2010 23:45, Alan Gauld wrote:
>
> "C M Caine" wrote
>>
>> My intention now is to modify list contents in the following fashion:
>>
>> for index, value in enumerate(L):
>> L[0] = some_func(value)
>
> I think you mean:
>
>> What other strange behaviour should I expect from for loops?
>
> You should read up on immutable data types like strings and tuples.
> Start with [1].
>
> Greets
> Sander
>
> [1] http://docs.python.org/reference/datamodel.html
>
Thank you kindly for your reply, I'll be sure to read up on it.
C
Thank you for the clarification, bob.
For any future readers of this thread I include this link[1] to effbot's
guide on lists, which I probably should have already read.
My intention now is to modify list contents in the following fashion:
for index, value in enumerate(L):
L[0] = some_func(v
Why does this not work:
>>> L = [' foo ','bar ']
>>> for i in L:
i = i.strip()
>>> L
[' foo ', 'bar ']
>>> # note the leading whitespace that has not been removed.
But this does:
>>> L = [i.strip() for i in L]
>>> L
['foo', 'bar']
What other strange behaviour should I expect from for loops?
Spir sent this solely to me by accident, I think.
-- Forwarded message --
From: spir ☣
Date: 2010/4/19
Subject: Re: [Tutor] List index usage: is there a more pythonesque way?
To: cmca...@googlemail.com
On Mon, 19 Apr 2010 12:59:40 +0100
C M Caine wrote:
> That's t
n, 19 Apr 2010 00:37:11 +0100
> C M Caine wrote:
>
>> That's two new things I've learnt. I didn't realise that for loops
>> could be used like that (with more than one... key?).
>
> Consider considering things differently: a for loop always iterates over
>
t's the first time I've heard of it; I'm trying to keep
the number of outside modules to a minimum as this is an assessed
piece of work.
Thanks, Bob.
On 19 April 2010 00:34, bob gailer wrote:
> On 4/18/2010 6:53 PM, C M Caine wrote:
>>
>> # Example data for forms
That's two new things I've learnt. I didn't realise that for loops
could be used like that (with more than one... key?).
Thanks, I'm changing my code even now!
On 19 April 2010 00:09, Alan Gauld wrote:
>
> "C M Caine" wrote
>
>> for i i
# Example data for forms and timetable:
forms = ["P7", "P8", "P9", "P10", "P11", "S7", "S8", "S9", "S10",
"S11", "IMA", "CAT", "FOR", "RLS", "EMPTY"]
timetable = ['CAT', 'P10', 'P8', 'EMPTY', 'EMPTY', 'EMPTY', 'S10',
'S8', 'IMA', 'EMPTY', 'S7', 'S10', 'P9', 'EMPTY', 'EMPTY', 'EMPTY',
'S7', 'EMPTY'
> Whilst I agree with the general principle to use raw_input, I don't
> see how we can say that it is the problem here. Indeed so far as
> I can tell we don't even know what the problem here is other than
> that the OP is trying to call the function he has defined in
> another file.
>
>
> --
> Alan
That's an easy mistake to make. Simply use raw_input instead of input.
The former will always return a string, the latter treats whatever you
enter as executable python code.
You almost never want to use input. raw_input is safer.
On 13 March 2010 18:56, Marco Rompré wrote:
>
> Hello I have a li
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 = []
>>
>>
>> >>
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:
player.hand.append("A")
>>> hands()
>>>
>>> Colin.ha
20 matches
Mail list logo