Re: [Tutor] IOError with fcntl.ioctl

2005-08-16 Thread Richi
Hi, All. Crave pardon if that question of mine was too basic to merit a reply, but I couldn't find anything by searching. Newbie Python user here. I finally did find the answer and thought I'd post it in case someone might come along with the same question. The problem is with the way I was us

Re: [Tutor] Very simple question

2005-08-16 Thread Kent Johnson
Jack Hartland wrote: > Hello > i am just starting out with python and have already hit a problem! > howdo you create a new line! i have tryed tab etc and enter runs the > command. Please help Take a look at Danny Yoo's IDLE tutorial: http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ Kent __

[Tutor] Very simple question

2005-08-16 Thread Jack Hartland
Hello i am just starting out with python and have already hit a problem! howdo you create a new line! i have tryed tab etc and enter runs the command. Please help -- Many Thanks Jack Hartland ___ Tutor maillist - Tutor@python.org http://mail.python

Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quickquestions

2005-08-16 Thread D. Hartley
Thanks, everyone! On 8/16/05, Michael Lange <[EMAIL PROTECTED]> wrote: > On Mon, 15 Aug 2005 22:51:20 -0400 > Kent Johnson <[EMAIL PROTECTED]> wrote: > > > I think Luke's suggestion will work if you use f.read() (to read the whole > > file as a single string) instead of f.readlines() and f.write

Re: [Tutor] Silly loop question

2005-08-16 Thread Alan G
> changeIndex = None > al = len(line) > for i in range(al): And theres the problem. Pythonprovides two loops, for is really a *foreach* so if you don't want to process *each* item - eg by jumping forward - then you really should use while and manage the index thataway. You can hack about with the

Re: [Tutor] deriving class from file to handle input line numbers?

2005-08-16 Thread Duncan Gibson
I wrote: > > class MyFile(file): > > etc > > > > I couldn't see how to have an instance of MyFile returned from the > > built-in 'open' function. I thought this was the crux of the problem. Kent Johnson replied: > open() is actually just an alias for file(): > >>> open is file > Tru

Re: [Tutor] deriving class from file to handle input line numbers?

2005-08-16 Thread Kent Johnson
Duncan Gibson wrote: > Kent Johnson wrote: > To be perfectly honest, I didn't try it because even if I had declared > > class MyFile(file): > etc > > I couldn't see how to have an instance of MyFile returned from the > built-in 'open' function. I thought this was the crux of the probl

Re: [Tutor] deriving class from file to handle input line numbers?

2005-08-16 Thread Duncan Gibson
Kent Johnson wrote: > If you just want to keep track of line numbers as you read the file by lines, > you could use enumerate(): > > f = open('myfile.txt') > for line_number, line in enumerate(f): > ... This is neat, but not all of the parsers work on a 'line by line' basis, so sometimes there

Re: [Tutor] Regexp with multiple patterns in Python

2005-08-16 Thread Kent Johnson
Kristian Evensen wrote: > What I want to do is to check for two patterns to make sure all > occurrences of pattern1 and pattern2 come in the same order as they do > in the file I parse. It it contains a number of computer-games I would > like the output to look something like this: > > PC, Batt

Re: [Tutor] LiveWires problems

2005-08-16 Thread Michael Murphy
Compiling it in Root worked, thanks. On 8/16/05, Luis N <[EMAIL PROTECTED]> wrote: > On 8/15/05, ZIYAD A. M. AL-BATLY <[EMAIL PROTECTED]> wrote: > > On Mon, 2005-08-15 at 11:52 -0400, Michael Murphy wrote: > > > Hi all > > > > > > I'm having problems with installing LiveWire for python for Linux >

Re: [Tutor] Silly loop question

2005-08-16 Thread Kent Johnson
mailing list wrote: > Hi all, > > I should know this, but it seems to elude me at present. > > I have a loop which is looping through a line of chars by index. > > So, one of these - > > for i in range(len(line)): > > > Now, question is, is there a simple way to 'fast forward' index i?

Re: [Tutor] convert a file from plaintext(Ascii) to unicode? very quickquestions

2005-08-16 Thread Michael Lange
On Mon, 15 Aug 2005 22:51:20 -0400 Kent Johnson <[EMAIL PROTECTED]> wrote: > I think Luke's suggestion will work if you use f.read() (to read the whole > file as a single string) instead of f.readlines() and f.write() instead of > writelines(). > > Kent > And if you want to convert ascii into

Re: [Tutor] deriving class from file to handle input line numbers?

2005-08-16 Thread Kent Johnson
Duncan Gibson wrote: > I was sure that this must be a frequently asked [homework?] question, > but trying to search for 'file open line number' didn't throw up the > sort of answers I was looking for, so here goes... > > I regularly write parsers for simple input files, and I need to give > helpfu

[Tutor] Silly loop question

2005-08-16 Thread mailing list
Hi all, I should know this, but it seems to elude me at present. I have a loop which is looping through a line of chars by index. So, one of these - for i in range(len(line)): Now, question is, is there a simple way to 'fast forward' index i? At the moment, I'm doing it like this - c

[Tutor] deriving class from file to handle input line numbers?

2005-08-16 Thread Duncan Gibson
I was sure that this must be a frequently asked [homework?] question, but trying to search for 'file open line number' didn't throw up the sort of answers I was looking for, so here goes... I regularly write parsers for simple input files, and I need to give helpful error messages if the input is

Re: [Tutor] LiveWires problems

2005-08-16 Thread Luis N
On 8/15/05, ZIYAD A. M. AL-BATLY <[EMAIL PROTECTED]> wrote: > On Mon, 2005-08-15 at 11:52 -0400, Michael Murphy wrote: > > Hi all > > > > I'm having problems with installing LiveWire for python for Linux > > (Linspire 5.0 to be exact) and I'm having trouble compiling setup.py. > > Heres the results

[Tutor] IOError with fcntl.ioctl

2005-08-16 Thread Richi
Hi, I'm trying to get the number of bytes available on an open serial device (on Linux). I try the following commands: >>> import os >>> import fcntl >>> import termios >>> fd = os.open ("/dev/ttyS0", os.O_RDWR) >>> fcntl.ioctl (fd, termios.TIOCINQ) and after the last line I get the follow