Forum: Poser Python Scripting


Subject: problems with readline in poser. help!

nightfir opened this issue on Jun 21, 2005 ยท 2 posts


mkrueger posted Tue, 21 June 2005 at 2:00 PM

Hi,

2 things:
first:
you have to escape the backslash, since t is a tab character:
filename = 'c:test.txt'
or use a slash:
filename = 'c:/test.txt'
or use a raw string, prepending a 'r':
filename = r'c:test.txt'

second:
readline is a method which has to invoked on a file object, in your case f:
line = f.readline()

You need the 'r' as second argument in open, since this specifies that you open the file for read access.
Also, don't forget to close f with f.close() when you're finished.

the following code snippet should be all you need:

<br></br>for line in open('c:test.txt', 'r').readlines():<br></br>    print line<br></br>

2 remarks:

Hope that helps, good luck!

martin