[Python-Dev] file.writelines("foo\n","bar\n")

Tim Peters tim.one@home.com
Mon, 28 May 2001 21:14:16 -0400


[Martin v. Loewis]
> ...
> Because it is a METH_OLDARGS method, you can do
>
> f=open("/tmp/x","w")
> f.writelines("foo\n","bar\n")
>
> With my upcoming patches, I'd replace this with METH_O, making this
> call illegal. Does anybody see a problem with that change in
> semantics?

Guido won't, and if he had even a twinge of doubt, Thomas's explanation of
how this bug was introduced in 2.0 would erase it.  The list.append() docs
were arguably unclear when that brouhaha hit, but there's nothing unclear
about the file.writelines() docs.

OTOH, the file.writelines() docs still say a list is required, not "a
sequence" as the 2.0 (+ current) code actually implements.

Hmm.  Wonder whether writelines() should be generalized to allow an iterable
object?