Re: [Tutor] getting original pattern from regular expression object

2010-04-19 Thread Rich Lovely
On 20 April 2010 03:25, Tino Dai wrote: > If I have: > > import re > a=re.compile('foo') > > is there a way to get the original pattern of foo from the object a? > > Thanks, > Tino > > > ___ > Tutor maillist  -  tu...@python.org > To unsubscribe or chang

[Tutor] getting original pattern from regular expression object

2010-04-19 Thread Tino Dai
If I have: import re a=re.compile('foo') is there a way to get the original pattern of foo from the object a? Thanks, Tino ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tu

Re: [Tutor] Guess my number? Guess what's wrong!

2010-04-19 Thread Matthew Carpenter-Arevalo
Thanks! On Sat, Apr 17, 2010 at 1:32 PM, Jim Byrnes wrote: > Matthew Carpenter-Arevalo wrote: > >> Hi Everyone, >> >> I'm a beginner python programmer, and I've been working on >> the perennial 'guess my number' example. >> >> When I run this in my module, I get an infinite loop of 'higher' or

[Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread C M Caine
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 the first I'v

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread Wayne Werner
On Mon, Apr 19, 2010 at 9:23 AM, Alan Gauld wrote: > > "C M Caine" wrote > >> That's the first I've read of iterating through dictionaries, I'd >> >> assumed it was impossible because they're unordered. >> > > Iteration doesn't require order, only to get each item once. > Even in very old Python

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread Alan Gauld
"C M Caine" wrote That's the first I've read of iterating through dictionaries, I'd assumed it was impossible because they're unordered. Iteration doesn't require order, only to get each item once. Even in very old Python versions you could iterate a dictionary via the keys() method. More

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread C M Caine
That's the first I've read of iterating through dictionaries, I'd assumed it was impossible because they're unordered. Your explanation for defining your own iterables is much easier to understand than the one I read before as well. Thanks again. 2010/4/19 spir ☣ : > On Mon, 19 Apr 2010 00:37:11

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread spir ☣
On Mon, 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 items of a collection you indicate: l = [1,2

Re: [Tutor] List index usage: is there a more pythonesque way?

2010-04-19 Thread ALAN GAULD
> 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?). Technically its still one key but enumerate returns a tuple of index and value and we use tuple unpacking to assign the values to the loop variables. That is we could writ