473,499 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to include text data in source code?

Sun
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.

Feb 1 '08 #1
3 1233
On Feb 1, 9:28 am, "Sun" <a...@hut.atwrote:
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
Feb 1 '08 #2
On Feb 1, 2:28 pm, "Sun" <a...@hut.atwrote:
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.
Heres a pointer to the use of the stringio module used to make text
look like a file:
http://en.wikipedia.org/wiki/Doctest...nique_words.py

- Paddy.
Feb 1 '08 #3
Sun

"Matimus" <mc******@gmail.comwrote in message
news:7d**********************************@i12g2000 prf.googlegroups.com...
On Feb 1, 9:28 am, "Sun" <a...@hut.atwrote:
>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
Thanks you all for the answers.

The reason is that I am using pydot to deal with graphiz dot format data,
which in my case is a very simple graph, just few lines. So i was trying to
just embed this data within the code. One functiuon will read in the data
and parse it as in "dot language" format.

Feb 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1494
by: John Smith | last post by:
I'm having the folowing problem: I'm getting an Array from an external source, the data in the array depents on the get variables. These get variables should be decided by the browser, after...
1
1757
by: Ola Theander | last post by:
Dear subscribers I'm currently creating a small application that will run at the end of a web installation to configure a SQL Server. For this task I have a SQL batch file in the same format...
9
13084
by: bill | last post by:
Forget the exact definition of difference between, #include <foo.h> and #include "bar.h" Normally foo.h is a standard header file, so it's path is not defined in compiler option, but I...
12
1959
by: Francois Grieu | last post by:
Can #include safely use a preprocessing token, as in #define HEADERFILE "stdio.h" #include HEADERFILE int main(void) {return printf("Hello, world\n")*0;} TIA, François Grieu
5
2492
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
3
2689
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
1
1062
by: thrikris | last post by:
I am trying to use a include file to include a whole bunch of text data in my source cpp file. This text data can change so I have to maintain it as a separate file and have something that works...
17
1708
by: Francine.Neary | last post by:
I have a program that uses a large lookup table, provided as a large array in the source: static int bigtbl={123, 456, /* etc. etc. */ 9999 }; Now this table is pretty big, and having it...
3
1285
by: vippstar | last post by:
Is this a valid implementation of stdio.h? -- stdio.h -- #ifndef __STDIO_H #define __STDIO_H /* all the necessary declarations etc */ void __dummy(void); void __dummy(void) { return;...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5467
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.