School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,480 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,788 people online right now. Registration is fast and FREE... Join Now!




text documents as variables

 

text documents as variables, I'm attempting to assign numbers in a text document as a varible

valarauca

21 May, 2009 - 11:27 AM
Post #1

New D.I.C Head
*

Joined: 20 May, 2009
Posts: 1

My issue is I have information in a text document (I want to keep it there for its abilitiy to be changed), But for the inforamation to be any use i need to assign it as a varrible.

here is what i got so far:

CODE


a = open('c:\qoo\a.txt', 'r')
a.seek(5)
a.read(3)



This gives me what i want, now how do i get it into a varible?

User is offlineProfile CardPM
+Quote Post


girasquid

RE: Text Documents As Variables

21 May, 2009 - 11:42 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,628



Thanked: 53 times
Dream Kudos: 825
My Contributions
Which line gives you want you want? If the value returned by seek(), does, it's trivial to store it:
python

foo = a.seek(5)
bar = a.seek(3)

User is offlineProfile CardPM
+Quote Post

n00bc0der

RE: Text Documents As Variables

5 Jun, 2009 - 04:41 AM
Post #3

D.I.C Head
**

Joined: 27 Nov, 2008
Posts: 62



Thanked: 3 times
My Contributions
I'd recommend opening the file, reading it to an array, changing the array in the ways it needs to be, and then writing the array to a file. This seems like the easiest way to do it.

Chris
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:49AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month