I'm having another crack at python - and I am enjoying the clean simple syntax - but one thing I couldn't work out was how to read a line from a file until a '\t' character.

How could I do this?

It is a phone-book program and the data is stored as follows:

Name + '\t' + Number + '\n'
5 Years
Discussion Span
Last Post by Shift_

Gribouillis could you explain that a little please

line.strip() returns a string with white space removed at both ends (white space is a space or tabulation or newline character). line.split() splits the line into pieces separated by white space and returns a list of the pieces. For example

>>> line = "John\t000000000000000\n"
>>> print( line.strip().split() )
['John', '000000000000000']

Then name, number = ['John', '000000000000000'] defines 2 string variables, name has value 'John' and number has value '000000000000000'.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.