Writelines() a bit confusing

Steve Holden steve at holdenweb.com
Sat May 19 09:36:53 EDT 2007


aiwarrior wrote:
> If file.WriteLines( seq ) accepts a list and it says it writes lines,
> why does it write the whole list in a single line. Be cause of that
> the reverse of file.writelines(seq) is not file.readlines().
> Are the assumptions i made correct? If yes why is this so?
> 
> I find a function called writelines not actualy writing the list in
> lines wierd.
> 
> [code]
> something = ['re','ri','ro']
> f.writelines( something )
> something_else = f.readlines()
> [/code]
> In this case the list something_else will be diffrent from something
> 
Your list is *not* what you would get in from a call to readlines.

Try it.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
------------------ Asciimercial ---------------------
Get on the web: Blog, lens and tag your way to fame!!
holdenweb.blogspot.com        squidoo.com/pythonology
tagged items:         del.icio.us/steve.holden/python
All these services currently offer free registration!
-------------- Thank You for Reading ----------------




More information about the Python-list mailing list