stem (using IDLE):
>>> n = "colourless"
>>> o = "colourless"
>>> n == o
True
>>> n is o
True
>>> p = "green ideas"
>>> q = "green ideas"
>>> p == q
True
>>> p is q
False
Why the differe
there been heated debate about this (e.g. in the context
of Python 3, where the change to the division operator has
apparently already provoked heated debate)?
Also, by the way, is there some obvious reason for Python's use
of the notation x + yj, rather than the more standard (except
per
This is partly a test to see if I can reply in the correct format
to a message in the tutor list (which I receive in digest format).
>Date: Thu, 02 Jul 2009 20:39:28 +1000
>From: Lie Ryan
>
>Angus Rodgers wrote:
>[...]
>>>>> p = "green ideas"
>>>
This is partly a test to see if I can reply in the correct format
to a message in the tutor list (which I receive in digest format).
>Date: Thu, 02 Jul 2009 20:39:28 +1000
>From: Lie Ryan
>
>Angus Rodgers wrote:
>[...]
>>>>> p = "green ideas"
>>>
>Date: Fri, 03 Jul 2009 12:46:06 +0100
>From: Angus Rodgers
>To: tutor@python.org
>Subject: Re: [Tutor] When are strings interned?
>Message-ID:
>Content-Type: text/plain; charset=us-ascii
>[...]
>Date: Fri, 03 Jul 2009 14:43:21 +0100
>From: Angus Rodgers
>To:
>Date: Sat, 04 Jul 2009 00:25:13 +1000
>From: Lie Ryan
>Message-ID:
>
>Angus Rodgers wrote:
>
>> I /think/ I would be naturally inclined to define:
>>
>> floor(x + yj) = floor(x) + floor(y)j for all real x, y
>>
>> z % w = z - floor(z / w)
about ("unknown unknowns").
Any comments? (I don't expect the Spanish Inquisition!)
--
Angus Rodgers
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
>Date: Sat, 04 Jul 2009 13:26:12 +0100
>From: Angus Rodgers
>Message-ID:
>
><http://python.pastebin.com/d7e245e0f> (retention: 1 day)
This is just a quick(ish!) response to the feedback so far.
I realise, now, that I should have quoted what the exercise in the
book was a
typ.__name__
>else: # User has provided an object of the correct type
> ans[key] = val
>return ans
>
I don't see this, because, if an exception does occur, won't
there be an attempt to access one of the objects 'key', 'val'
before
ies instead, with the denomination names
as keys? Is it possible to guarantee a sequence in which the keys
of a dictionary are iterated through? (If not, I suppose I could
keep the list 'denom' as it is here, and iterate through it with
"for key in denom:", although this seems a b
On Sun, 5 Jul 2009 18:49:32 -0400, Kent Johnson wrote:
>On Sun, Jul 5, 2009 at 2:48 PM, Angus Rodgers wrote:
>
>> for i in range(LEN - 1):
>> (count[i], amnt) = divmod(amnt, value[i])
Incidentally, I forgot to quote the next line:
count[-1] = m
Of course, this is much b
;(count, amnt) = divmod(amnt, val)
>counts[val] = count
Better, of course (I still haven't run it, but it should work):
counts = {}
for val in value:
(counts[val], amnt) = divmod(amnt, val)
>I'm much happier now, thanks!
... but also rather annoyed with myself.
Thanks to all of you. I haven't adopted the suggestion of using
classes, which I think I'll leave for when I'm reading the later
chapters of the book (although I do get the gist of the idea).
--
Angus Rodgers
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
a...@bermanrl-desktop>
>
>While it is not a sales pitch, the book is excellent. It and the Python
>Cookbook sit on top of my desk. Both are fantastic and pragmatic
>reference sources.
>>> happy.append(me)
>>> len(happy)
5
--
Angus Rodgers
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
lies like a banana.
--
Angus Rodgers
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
return i
return -1
def subchr(strng, origchar, newchar):
chars = list(strng)
for i, c in enumerate(chars):
if c == origchar:
chars[i] = newchar
return ''.join(chars)
I've quoted all my code, in case it's all
#x27;abcdeefghijkl' BINGO. Done.
>
>Is that not a bit simpler
I did explain (perhaps at too great a length, or with too many
irrelevancies):
>On Fri, 2009-07-10 at 16:24 +0100, Angus Rodgers wrote:
>> [...]
>> On the earlier occasion:
>> [...]
>> I wrote:
>&
if ch in '+-' and num[i] not in 'eE':
return complex(float(num[:i + 1]),
float(num[i + 1:-1]))
return complex(float(num), 0.0)
--
Angus Rodgers
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
use it in this one), and then the bit in the second
message where I repeated this information, carefully and briefly,
because you seemed to have missed it the first time! I hope I'm
not being rude, but I just don't know what else to say. I can't
see that I'
# Case (iv)
return complex(float(num[:i + 1]),
-float(num[i + 2:-1]))
# Case (i)
return complex(float(num), 0.0)
(I have manually wrapped a few longish lines, just for this post
to the mailing list - the longest was 76 characters long. I've
also corrected another bug that was in the original program - it
didn't check that the final [non-space] character was actually a
'j'.)
--
Angus Rodgers
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
20 matches
Mail list logo