User Profile

Collapse

Profile Sidebar

Collapse
Traclo
Traclo
Last Activity: Mar 25 '08, 02:01 PM
Joined: Oct 14 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Ahh ok I've got it.
    I just added a function to the tableau class that can be called by main to pass the self.stock to to the tableau after it's created.

    Again an embarrassingly simple solution.
    Sorry for the trouble and thank you for the time.
    See more | Go to post

    Leave a comment:


  • Thank you very much for responding.
    The problem with that solution for me is that the __init__ of the main class has a value that is an instance of the imported class. Here is the simplified troublesome part of the code:

    Code:
    class Main(object):
    
        def __init__(self):
    
            root = Tk()
            root.title = "Spider Solitaire"
            self.set_up_deck()
            self.load_card_images()
    ...
    See more | Go to post

    Leave a comment:


  • Using a function from __main__ from within an imported module

    Hello all,
    I was hoping that someone could help me out with a python programming question.
    I have a main program that imports a module which consists of a class. What I cannot seem to do is get a function of this class to direct the program to a function in the main program.

    Basically:

    What is in the module:
    Code:
    class():
        def random_function():
            call_function_from_main()
    ...
    See more | Go to post

  • Traclo
    replied to Heapify, bad syntax
    Well this is embarrassing.
    See more | Go to post

    Leave a comment:


  • Traclo
    started a topic Heapify, bad syntax

    Heapify, bad syntax

    With this code I'm trying to create a huffman encoding tree, to compress text. But heapify just won't work for me :(

    Code:
    def create_tree(dict):
        listofNodes = []
        for element in dict.items():
            newNode = Node(weight = element[1], item = element[0])
            listofNodes.append(newNode)
        listofNodes.append(Node(weight = 1, item = 'eof')
        heapify(listofNodes)
        while len(listofNodes)
    ...
    See more | Go to post

  • Traclo
    replied to askopenfilename - A tkFileDialog problem
    Thanks that worked perfect!
    See more | Go to post

    Leave a comment:


  • Traclo
    started a topic askopenfilename - A tkFileDialog problem

    askopenfilename - A tkFileDialog problem

    Hello all! I have a problem concerning tkFileDialog. When I use the the askopenfilename command to open a text file it opens a tkinter window (apart from the file browsing window) which refuses to close once I've selected and opened the file. It just stays there and when clicked on says not responding.

    I am using Vista, writing this file in Wing, and have the latest version of python

    My code for this interaction goes...
    See more | Go to post

  • Traclo
    replied to Help with a function!
    Solved! It was because list[-1] was actually \n because it was going to a new line.
    so I put list.strip()[-1] and life got 10x better.

    Thank you for the help (helped me fix some errors :D)
    See more | Go to post

    Leave a comment:


  • Traclo
    replied to Help with a function!
    Embarrassing! So many tiny flaws in my programming, but I guess that's why I'm still learning. Again I've corrected the mistake in my first post by making raw_number refer to line[0:-1]
    But I'd say that isn't the problem. Because if it were working correctly then it shouldn't have printed any numbers for "print line" because none of the last numbers were equal to the check sum!

    So again for some reason the line[-1]...
    See more | Go to post

    Leave a comment:


  • Traclo
    replied to Help with a function!
    My apologies! That was a remnant of previous version of the code. I have corrected e to line. But unfortunately that isn't the source of the error :(
    See more | Go to post

    Leave a comment:


  • Traclo
    started a topic Help with a function!

    Help with a function!

    I wrote this function for my introductory programming class in university. It is used to verify that an ISBN is valid. It does this by checking the calculated checksum of the number to the last digit of the number. It is supposed to do this for an entire txt file.

    Code:
    def verify_isbn_file():
        file_name = pick_a_file()
        input_file = open(file_name)
        
        for line in input_file:
            initial_multiplier
    ...
    See more | Go to post

  • Traclo
    started a topic TypeError: 'str' object is not callable

    TypeError: 'str' object is not callable

    I am doing a computer science project and I have to take a string that contains numbers, double each number individually and then return the doubled integers as one large string.

    I tried this code:

    def double_my_digit s(str):
    new_digits = []
    for c in str:
    b = int(c)
    a = b*2
    x = str(a)
    new_digits.appe nd(x)
    return "".join(new_dig its)...
    See more | Go to post
No activity results to display
Show More
Working...