Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Dec 10th, 2005, 2:19 PM   #1
UnKnown X
Hobbyist Programmer
 
UnKnown X's Avatar
 
Join Date: Dec 2005
Location: Sandvika, Norway
Posts: 114
Rep Power: 0 UnKnown X is an unknown quantity at this point
Send a message via MSN to UnKnown X
Reading numbers from file

I read ColdDeath's (brilliant ) tutorial, and decided to give Python a shot. So I made a programme that finds a Fibonacci number a few hours ago. Then I decided to come back and try to make it read from and write the results to a file.

Now, I can't figure out how to make it read the last number! The numbers are saved like this:
1
1
2
3
5
8
13
21
34
55
and so on (including the last newline)


I tried this, but it didn't work. I'm not sure where or why it fails:
        k = 1
        while (f.seek(k * -1, 2)) != '\n':
            k += 1
        k -= 1
        f.seek((f.read())-(f.read()-k))
        b = int(f.read((f.read())-(f.read()-k)))
        k += 2
        while (f.seek(k * -1, 2)) != '\n':
            k += 1
        k -= 1
        f.seek((f.read())-(f.read()-k))
        a = int(f.read((f.read())-(f.read()-k)))
        f.seek(0, 2)
UnKnown X is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC