User Profile

Collapse

Profile Sidebar

Collapse
MaxLindquist
MaxLindquist
Last Activity: Jan 9 '07, 07:47 PM
Joined: Oct 26 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • MaxLindquist
    started a topic time.clock() in unix

    time.clock() in unix

    I wanna make a stopwatch. I did this on windows and it worked perfectly. When then used the same program on Unix it didn't work. I have checked in the pythonlibrary, but i can't find anything.

    This is my simple code:

    Code:
    import time
    
    t1=time.clock()
    
    g=raw_input("Wait a sec and press enter")
    
    t2=time.clock()
    
    print t2-t1
    ...
    See more | Go to post

  • MaxLindquist
    replied to Highscore
    ok.... now i understand!
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    But what does this mean then?...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    i Have one last question:

    What does this part do?
    Code:
    if __name__ == '__main__':
        try:
            highscore2()
        finally:
            del highscore2
            del columnize
    what is "del"?
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    Okey... i get it now... thank you very much for your help! I truly mean it!
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    But can i add new players to the highscore now.
    Beacause now the highscore is part of the code:
    Code:
        oldscores = [(300, 'John', 1, 300, 12), (200, 'Jane', 200, 3, 4), (106, 'Bajs', 1, 106, 9), (102, 'Hej', 1, 102, 9), (83, 'test', 2, 41, 48), \
                      (68.700513199546208, 'Testny', 1, 68, 14.555932021867418), (66, 'Runk', 1, 66, 15), (58, 'test', 1, 58, 16), \
                      (53, 'Test4', 1, 53, 18)]
    ...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    This is the Errormessage:

    Code:
    >>> 
    Total Score        Name               Times Played       Median Value       Total time played (sec)
    
    Traceback (most recent call last):
      File "D:\Python24\Test.py", line 25, in -toplevel-
        highscore2()
      File "D:\Python24\Test.py", line 22, in highscore2
        print columnize(col_value, column_width),
      File
    ...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    It exactly what i had in mind... this doesn't work on my cpu though. Maybe col_value has to be defined or something?...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    Thank you.... now it works prefectly. I inserted some extra stuff:

    Score, Name, Times Played, Total time played.

    I have now only one last question:

    When i print this out, how do I make this look good? Now it prints out this:

    (Total Score, Name, Times Played, Median Value, Total time played (sec))
    (300, 'John')
    (200, 'Jane')
    (106, 'Bajs', 1, 106, 9)
    (102, 'Hej',...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    Actually that was all of my code... I just want that part of the program to work, then i'm gonna put it in my big program, the game i am making...

    But this is my code:

    Code:
    hiscores = [(300, "John")]
    score=raw_input("Score?")
    player=raw_input("Name?")
    hiscores.append((score, player))
    print hiscores
    
    hiscores.sort()
    print hiscores
    ...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    This is the code:

    hiscores = [(300, "John")]
    score=raw_input ("Score?")
    player=raw_inpu t("Name?")
    hiscores.append ((score, player))
    print hiscores

    hiscores.sort()
    print hiscores



    import pickle

    scores=open("sc ores", "w")
    pickle.dump(his cores[-10:], scores)
    scores.close()
    ...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    I tried this code... I created at textfile, called "score.txt" next to my program, and i changed score and player to raw_inputs. But if i run it a second time, the information from previous time isn't saved....
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    How would you do it if you used a lists? Like:
    score=list()
    name=list()

    in some way?
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    OK.... i think i get it now... thanks
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    Thanks! What does pickle do?
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    replied to Highscore
    Yes.... I mean.... i want to make my program save the top 10 scores and names in some way....
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    started a topic Highscore

    Highscore

    Hi! I want to make a highscore for a game i am making. How might i do that?

    Thanks
    See more | Go to post

  • Thanks... hehe... actually it was the most obvious one i was looking for...
    See more | Go to post

    Leave a comment:


  • MaxLindquist
    started a topic Search for letters in a String [solved]

    Search for letters in a String [solved]

    How do i search for one letter in a String? For example the third letter in Word="Hello". The thought is that i that way can use:

    if (the third letter in Word)=="l":

    Thanks!
    See more | Go to post

  • MaxLindquist
    replied to How to make a String an Int [solved]
    Im making a dicegame. I'm an absoulte beginner and i am not very good with computers, so a am very thankful for your help!
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...