[Bf-python] OBJ import (another bug?)

Stephane SOPPERA stephane.soppera at wanadoo.fr
Mon Oct 4 22:06:24 CEST 2004


Campbell Barton wrote:

> Well I did a dos2unix using nedit. open and save- then it works.
>
> The line seperation is done with pythons readlines so mabe there is a 
> but with that???
>
> Im just saying the bug is in the readlines function, since its read as 
> 1 line. (I tested this)

Actually this file's lines are separated by only a '\r'. Usually, lines 
are separated with a '\n' on unix and '\r\n' on windows.
Since "\r" means that the cursor should return at the start of the line 
without going to the next line, the following string: "hello\rworld\r!" 
should display "!orld". I've just checked that it's what python 
displayed when you type  print "hello\rworld\r!" on linux.
So the obj files on the site are misformed. They are not correct windows 
files.

Maybe something like:
string=file.read()
lines=string.split()
instead of:
lines=file.readlines()
will solve the issue and make the script works with misformed files.

I've tested on linux that "my\rstring\r\nis\nok".split() give ['my', 
'string', 'is', 'ok'] so it might be ok on other plateforms.

Bye,
Stephane

-- 
Stephane SOPPERA
http://perso.wanadoo.fr/stephane.soppera 





More information about the Bf-python mailing list