Insert character at a fixed position of lines

Lie Lie.1296 at gmail.com
Wed Jul 30 08:43:02 EDT 2008


On Jul 27, 10:02 am, alex23 <wuwe... at gmail.com> wrote:
> Ugh, and in pointing our your inaccurate code I posted my own:
>
> > >>> f = open('dummy.txt','w')
> > >>> f.write(line = 'this doesn't work')
>
> >   File "<stdin>", line 1
> >     f.write(line = 'this doesn't work')
> >                                ^
> > SyntaxError: invalid syntax
>
> That should be:
>
> >>> f.write(line = "this doesn't work")
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: write() takes no keyword arguments
>
> Sorry about that :)

Lessons learned, should test codes even if you thought it seemed
trivial.



More information about the Python-list mailing list