<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>techniQal support - Latest Comments in Python: Simple File Read and Write</title><link>http://damniel.disqus.com/</link><description>the Q stands for quality</description><language>en</language><lastBuildDate>Thu, 12 Feb 2009 11:24:09 -0000</lastBuildDate><item><title>Re: Python: Simple File Read and Write</title><link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comment-6208695</link><description>Hi,&lt;br&gt;I am opening a file in r+ mode. I have a problem in this. If I first write in a file and then read the same file it is working fine. But some junk characters are added to the end of the string. &lt;br&gt;Also one more problem if I read it first say using readline function and then write it, the write operation doesn't happen. Any idea what might be the problem?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">karuppiah</dc:creator><pubDate>Thu, 12 Feb 2009 11:24:09 -0000</pubDate></item><item><title>Re: Python: Simple File Read and Write</title><link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comment-4521346</link><description>hi, how would you read the whole file in but exclude say the first 4 bytes of it?  &lt;br&gt;thanks&lt;br&gt;sean</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">shaun</dc:creator><pubDate>Fri, 19 Dec 2008 10:15:08 -0000</pubDate></item><item><title>Re: Python: Simple File Read and Write</title><link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comment-4486043</link><description>Well, &lt;br&gt;I would argue that the input is a list already. If you are wanting to return a subset of the GeneCode list, I would do the following.  There are more graceful ways to achieve this, but this method shows you the logic involved.&lt;br&gt;&lt;br&gt;x = [0,1,2,3]&lt;br&gt;GeneCode = ['AAAA','AAAC','AAAG','AAAT']&lt;br&gt;&lt;br&gt;def Li_to_GC(x):&lt;br&gt;	newList = [GeneCode[i] for i in x]&lt;br&gt;	return newList&lt;br&gt;&lt;br&gt;print Li_to_GC(x)&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;In this case, you can then pass any numeric list to LI_to_GC and get the corresponding Genecodes list back.&lt;br&gt;I would check out this great List comprehension article here, and you can learn more. &lt;a href="http://effbot.org/zone/python-list.htm" rel="nofollow"&gt;http://effbot.org/zone/python-list.htm&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">damniel</dc:creator><pubDate>Thu, 18 Dec 2008 14:02:52 -0000</pubDate></item><item><title>Re: Python: Simple File Read and Write</title><link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comment-4464933</link><description>Thank you Daniel, another problem: &lt;br&gt;x = [0,1,2,3]&lt;br&gt;GeneCode = ['AAAA','AAAC','AAAG','AAAT']&lt;br&gt;def Li_to_GC(x):&lt;br&gt;    for i in x:&lt;br&gt;            print GeneCode[i],&lt;br&gt;Li_to_GC(x)&lt;br&gt;&lt;br&gt;How can convert the result to the list or string?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reza</dc:creator><pubDate>Wed, 17 Dec 2008 14:53:07 -0000</pubDate></item><item><title>Re: Python: Simple File Read and Write</title><link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comment-4053496</link><description>All you need to do is specify the location of the file you want to save to.&lt;br&gt;&lt;br&gt;So when opening the second file, specify the directory then. &lt;br&gt;Example on win32:&lt;br&gt;file = open("my_dir\\newfile.txt","w") &lt;br&gt;Example on *nix :&lt;br&gt;file = open("my_dir/newfile.txt","w")&lt;br&gt;&lt;br&gt;This will create the new file in the directory "my_dir" assuming the directory exists in the same folder as your python script. You can also specify an absolute file path as well.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">damniel</dc:creator><pubDate>Fri, 28 Nov 2008 14:55:59 -0000</pubDate></item><item><title>Re: Python: Simple File Read and Write</title><link>http://www.techniqal.com/blog/2005/05/17/python-simple-file-read-and-write/#comment-4053115</link><description>Hi, I have opened my file I have manipulated and I want save this new change in the other directory. At least I know that I should be use ' r ' for reading and ' w ' command for writing, but I do not know how I can make connection between readings and manipulate file and writing this manipulation in the other file.&lt;br&gt;Best Regards&lt;br&gt;Reza _ Finland</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reza</dc:creator><pubDate>Fri, 28 Nov 2008 14:04:54 -0000</pubDate></item></channel></rss>