Re: Buffer pair for lexical analysis of raw binary data

2009-06-28 Thread Angus Rodgers
On 28 Jun 2009 08:00:23 -0700, a...@pythoncraft.com (Aahz) wrote: >In article <0qec45lho8lkng4n20sb1ad4eguat67...@4ax.com>, >Angus Rodgers wrote: >> >>Partly as an educational exercise, and partly for its practical >>benefit, I'm trying to pick up a programm

Buffer pair for lexical analysis of raw binary data

2009-06-27 Thread Angus Rodgers
just get my hands dirty with some C++ compiler or other, and get my original code working on my present machine (possibly in ANSI C instead of C++), and call it from Python? -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 13:49:57 +0200, Peter Otten <__pete...@web.de> wrote: >Angus Rodgers wrote: > >> On Sat, 27 Jun 2009 13:02:47 +0200, Peter Otten >> <__pete...@web.de> wrote: >> >>>Angus Rodgers wrote: >>> >>>> On Sat, 27

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
w do you actually get to see the raw bytes of a file in Windows? OK, this seems to work: f = open('test001A.txt', 'rb') # Binary mode print repr(f.read()) Output: 'abc xyz\r\nBd ef\r\n\r\ngH ij\r\n' Indeed, when a Windows file is opened for reading in binary m

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 12:13:57 +0100, I wrote: >the \r\n sequence at the end of a Win/DOS file Of course, I meant the end of a line of text, not the end of the file. (I promise I'll try to learn to proofread my posts. This is getting embarrassing!) -- Angus Rodgers -- http://mail.py

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Sat, 27 Jun 2009 13:02:47 +0200, Peter Otten <__pete...@web.de> wrote: >Angus Rodgers wrote: > >> On Sat, 27 Jun 2009 11:39:28 +0100, I asked rhetorically: >> >>>Will your program handle empty lines of input correctly? >> >> Strangely enough,

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
+line[1:], > >Will your program handle empty lines of input correctly? Strangely enough, it seems to do so, but why? -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
On Fri, 26 Jun 2009 18:58:27 -0700 (PDT), powah wrote: >Thank you for your hint. >This is my solution: >f = open('test', 'r') >for line in f: >print line[0].upper()+line[1:], Will your program handle empty lines of input correctly? -- Angus Rodgers

Re: change the first character of the line to uppercase in a text file

2009-06-27 Thread Angus Rodgers
is my solution: >f = open('test', 'r') >for line in f: >print line[0].upper()+line[1:], I know this is homework, so I didn't want to say anything (especially as I'm a newcomer, also just starting to learn the language), but it seems OK to mention that if you hunt around some more in the standard library documentation, you'll find an even shorter way to write this. -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-27 Thread Angus Rodgers
ot;Among its chief virtues are the following four -- no, five -- no, six -- points: [...]" -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-26 Thread Angus Rodgers
On Thu, 25 Jun 2009 18:22:48 +0100, MRAB wrote: >Angus Rodgers wrote: >> On Thu, 25 Jun 2009 10:31:47 -0500, Kirk Strauser >> wrote: >> >>> At 2009-06-24T19:53:49Z, Angus Rodgers writes: >>> >>>> print ''.join(map(detab, f.xreadli

Re: It's ...

2009-06-25 Thread Angus Rodgers
On Thu, 25 Jun 2009 17:56:47 +0100, I found a new way to disgrace myself, thus: >[...] something like x.readlines()? ^ I don't know how that full stop got in there. Please ignore it! -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-25 Thread Angus Rodgers
;t mentioned in the index to the 2nd edition of Beazley's book)". Something like that! 8-P -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-25 Thread Angus Rodgers
On Thu, 25 Jun 2009 17:53:51 +0100, I wrote: >On Thu, 25 Jun 2009 10:31:47 -0500, Kirk Strauser > wrote: > >>At 2009-06-24T19:53:49Z, Angus Rodgers writes: >> >>> print ''.join(map(detab, f.xreadlines())) >> >>An equivalent in modern Pythons

Re: It's ...

2009-06-25 Thread Angus Rodgers
On Thu, 25 Jun 2009 10:31:47 -0500, Kirk Strauser wrote: >At 2009-06-24T19:53:49Z, Angus Rodgers writes: > >> print ''.join(map(detab, f.xreadlines())) > >An equivalent in modern Pythons: > >>>> print ''.join(line.expandtabs(3) for line in

Re: [SPAM] It's ...

2009-06-25 Thread Angus Rodgers
Someone has gently directed me to the Tutor mailing list: <http://mail.python.org/mailman/listinfo/tutor> which I hadn't known about. I've joined, and will try to confine my initial blundering experiments to there. Sorry about the spam spam spam spam, lovely spam, wonderful

Re: It's ...

2009-06-24 Thread Angus Rodgers
7;ll try to work through a textbook with exercises. But I thought I'd better try to get some quick feedback at the start, because I knew that I was fumbling around, and that it was unlikely to be necessary to use such circumlocutions.) -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-24 Thread Angus Rodgers
On Wed, 24 Jun 2009 14:10:54 -0700, Scott David Daniels wrote: >Angus Rodgers wrote: > >> from types import StringType # Is this awkwardness necessary? >Nope I'm starting to see some of the mental haze that was confusing me. >Also, expandtabs is an instance method, s

Re: It's ...

2009-06-24 Thread Angus Rodgers
clear, I'm sure, especially after I have written more than one one-line program!) -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

Re: It's ...

2009-06-24 Thread Angus Rodgers
On Wed, 24 Jun 2009 16:40:29 -0400, "J. Cliff Dyer" wrote: >On Wed, 2009-06-24 at 20:53 +0100, Angus Rodgers wrote: >> [...] >> from types import StringType # Is this awkwardness necessary? > >Not anymore. You can just use str for this. > >> detab =

Re: It's ...

2009-06-24 Thread Angus Rodgers
tp://www.python.org/doc/2.4/whatsnew/> <http://www.python.org/doc/2.5/whatsnew/> ... although there doesn't seem to be any <http://www.python.org/doc/2.2/whatsnew/> ... ah! ... <http://www.python.org/doc/2.2.3/whatsnew/> "What's New in Python 2.2" -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list

It's ...

2009-06-24 Thread Angus Rodgers
feet wet, and I'll try not to ask too many silly questions! First impressions are: (1) Python seems both elegant and practical; and (2) Beazley seems a pleasantly unfussy introduction for someone with at least a little programming experience in other languages. -- Angus Rodgers -- http://mail.python.org/mailman/listinfo/python-list