[Tutor] Append mode dilemma
bibsmendez at gmail.com
Wed Dec 9 20:02:22 CET 2009
> Luke Paireepinart wrote:
> That's because there is NOT a new line at the end of the file.
> It's a file you're appending to, it's up to YOU to create that new
> line. And all files should end with newlines anyway (on linux).
> So modify your code so that you output a new line at the end of your
> fobj = open(fname, 'a')
Quickie hack just to achieve the newline. Doesn't python have a function
that adds newline automatically in append mode?
fobj = open(fname, 'a')
Host/Kernel/OS "cc000002695" running Linux 2.6.31-5.slh.4-sidux-686
[sidux 2009-02 Αιθήρ - kde-full - (200907141427) ]
>> Are you aware of how 'join' works?
>> print "#".join(['a','b','c'])
>> at the interactive prompt and see if you can't figure out why you're
>> missing a newline at the end of your output.
> Hi Luke,
> Thank you. To be honest I'm confused of the different string methods
> like join(), split(), etc. Anyway I will practice them to see how they
More information about the Tutor