how to include text data in source code?

Matimus mccredie at gmail.com
Fri Feb 1 10:16:24 EST 2008


On Feb 1, 9:28 am, "Sun" <a... at hut.at> wrote:
> as the subject, I 'd like to know how to include a piece of text as input in
> the source code so that I do not need to read in data from files. I remember
> there is some thing like this in Perl, have no idea if python has the same
> thing?
>
> Thanks.

You can just add a big string to your file. Triple quotes will help
with that. Of course, if you are going to be entering the data into
your python file, why don't you enter it using the most appropriate
data structure. Were intending to also append to the data in the file?
I'm sure you could figure something out to do that, but there is no
inherent feature that does that automatically.

Matt



More information about the Python-list mailing list