In <[EMAIL PROTECTED]>, Gregory Petrosyan wrote: > Thanks for your reply. I understand this fact, but I wonder why > writelines() works slowly -- I think C code can be optimised to work > faster than Python one. Is it correct that writelines(...) is just a > shorthand for > > for ch in ...: > file.write(ch) > ?
Depends on `...`. If it's a string then yes because a string is a sequence of characters. But `writelines()` is ment for a sequence of strings. It's the counterpart of `readlines()`. Then it's just a shorthand for:: for line in lines: file.write(line) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list