On Wed, Dec 9, 2009 at 12:11 PM, biboy mendz <span dir="ltr"><<a href="mailto:bibsmendez@gmail.com">bibsmendez@gmail.com</a>></span> wrote:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello all!<br>
I'm trying to use the append mode when opening and writing to a file<br>
but i cant get it to work my way. When run in the present code,<br>
the user inputs are expectedly 'appended' but not in a newline below the last<br>
line of the existing file. <br></blockquote><div>That's because there is NOT a new line at the end of the file.</div><div>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).</div>
<div>So modify your code so that you output a new line at the end of your outputs. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
fobj = open(fname, 'a')<br>
fobj.write('\n'.join(all))<br>
fobj.close()<br><br></blockquote><div>Are you aware of how 'join' works?<br>try</div><div>print "#".join(['a','b','c'])</div><div>at the interactive prompt and see if you can't figure out why you're missing a newline at the end of your output.</div>
<div><br></div><div><br></div><div>HTH,</div><div>-Luke</div></div><br>