Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Steven D'Aprano
Josep M. Fontana wrote: Sorry about the top-posting. Sometimes it seems that a little top-posting might make things easier (I hate to have to go through long quotes) but you are totally right, netiquette is netiquette. To all the people who say "Never top-post", I say never say never -- there

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Steven D'Aprano
Josep M. Fontana wrote: The only time year is bound is in the previous loop, as I said. It's the line that goes: name, year = line.strip. So year is whatever it was the last time through that loop. OK, this makes sense. Indeed that is the value in the last entry for the dictionary. Th

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Josep M. Fontana
> The only time year is bound is in the previous loop, as I said.  It's the > line that goes: >     name, year = line.strip. > > So year is whatever it was the last time through that loop. OK, this makes sense. Indeed that is the value in the last entry for the dictionary. Thanks a lot again.

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Dave Angel
On 11/1/2010 1:53 PM, Josep M. Fontana wrote: Hi Dave, On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel wrote: (You top-posted, so I had to remove the out-of-order earlier portion.) I've not tried to run the code, but I think I can see the problem. Since you never assign 'year' inside the loop(s)

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Josep M. Fontana
Hi Dave, On Mon, Nov 1, 2010 at 2:38 PM, Dave Angel wrote: > (You top-posted, so I had to remove the out-of-order earlier portion.) > > I've not tried to run the code, but I think I can see the problem. Since > you never assign 'year' inside the loop(s), it's always the same. And it's > whatev

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Dave Angel
On 11/1/2010 8:48 AM, Josep M. Fontana wrote: Thanks a lot Dave and Joel, You call re.sub(), but don't do anything with the result. Where do you call os.rename() ? Yes, indeed, as you suggested what was missing was the use of os.rename() to apply the substitution to the actual file names. I

Re: [Tutor] Problems with partial string matching

2010-11-01 Thread Josep M. Fontana
Thanks a lot Dave and Joel, > You call re.sub(), but don't do anything with the result. > > Where do you call os.rename() ? Yes, indeed, as you suggested what was missing was the use of os.rename() to apply the substitution to the actual file names. I incorporated that and I changed the loop th

Re: [Tutor] Problems with partial string matching

2010-10-24 Thread Dave Angel
On 2:59 PM, Josep M. Fontana wrote: Hi, As I said in another message with the heading "Using contents of a document to change file names", I'm trying to learn Python "by doing" and I was working on a little project where I had to change the names I run this and I don't get any errors. The name

Re: [Tutor] Problems with partial string matching

2010-10-24 Thread Joel Goldstick
On Sun, Oct 24, 2010 at 2:16 PM, Josep M. Fontana wrote: > Hi, > > As I said in another message with the heading "Using contents of a > document to change file names", I'm trying to learn Python "by doing" > and I was working on a little project where I had to change the names > of the files in a