Re: Insert Content of a File into a Variable

2006-10-27 Thread Paul McGuire
"Wijaya Edward" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi, > > How can we slurp all content of a single file > into one variable? > Please don't double-post your questions. Now you have two threads running with people answering the same question. -- Paul -- http://m

Re: Insert Content of a File into a Variable

2006-10-26 Thread Cameron Walsh
Wijaya Edward wrote: > Hi, > > How can we slurp all content of a single file > into one variable? > > I tried this: > myfile_content = open('somefile.txt') print myfile_content, > > > > But it doesn't print the content of the file. >>> help(open) Help on built-in function ope

Re: Insert Content of a File into a Variable

2006-10-26 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > The 'read' method of the resulting file object will return the > contents of the file. You may also want to read the documentation of > thile objects to see what else you can do with them. And ith you couldn't underthtand my thpeetch impediment, I meanth "

Re: Insert Content of a File into a Variable

2006-10-26 Thread Ben Finney
Wijaya Edward <[EMAIL PROTECTED]> writes: > >>> myfile_content = open('somefile.txt') > >>> print myfile_content, > > >>> > > But it doesn't print the content of the file. That's right, because "the content of the file" is not what open() is documented to return; it is documented as returning a

Re: Insert Content of a File into a Variable

2006-10-26 Thread Steve Holden
Wijaya Edward wrote: > Hi, > > How can we slurp all content of a single file > into one variable? > > I tried this: > > myfile_content = open('somefile.txt') print myfile_content, > > > > > > But it doesn't print the content of the file. > Because you haven't read it! data

Re: Insert Content of a File into a Variable

2006-10-26 Thread Grant Edwards
On 2006-10-27, Wijaya Edward <[EMAIL PROTECTED]> wrote: > How can we slurp all content of a single file > into one variable? http://docs.python.org/tut/node9.html#SECTION00920 I suggest you read the rest of the tutorial as well. -- Grant Edwards grante

Insert Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
Hi, How can we slurp all content of a single file into one variable? I tried this: >>> myfile_content = open('somefile.txt') >>> print myfile_content, >>> But it doesn't print the content of the file. Regards, -- Edward WIJAYA SINGAPORE Institute For Infocomm Research -