473,623 Members | 2,439 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 1239
On Feb 1, 9:28 am, "Sun" <a...@hut.atwro te:
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.atwro te:
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******** *************** ***********@i12 g2000prf.google groups.com...
On Feb 1, 9:28 am, "Sun" <a...@hut.atwro te:
>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
1500
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 there decided I can created the adres to get the file with the JavaScript Array. How do I include this file??? Basicaly what I want in the script is something like: include(http://the.source.com/javascript/array.php?start=a&end=g);
1
1772
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 as SQL Query Analyzer uses. I would prefer not to merge the content of this file into the source code of configuration application but instead keep the SQL commands in a text file included in the executable, pretty much like resource data, for...
9
13100
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 am curious how compiler find it.
12
1978
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
2504
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 very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when dealing with complex software distributions. It occurs ot me that by extending the C include...
3
2697
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 directories contain a file named "cppfile1.h". In my main project I #include "cppfile1.h". I rely on the order of paths in additional include directories list to get file cppfile1.h from ProjectA and
1
1067
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 like a #include directive. Eventually I want a variable looking like this char *myStr = "all the text from include file here.......". uisng something like this.... char*myStr = "#include "somefile" ";
17
1723
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 clutter up my main source file is quite ugly. So I'd like to put it in a separate file and #include that.
3
1301
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; #include "closebracket.h"
0
8227
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8165
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8613
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8326
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2602
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1778
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1473
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.