User Profile

Collapse

Profile Sidebar

Collapse
KaezarRex
KaezarRex
Last Activity: Jun 5 '08, 01:55 PM
Joined: Sep 6 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • KaezarRex
    replied to add to file
    I don't know what language you are using, but in Python, this is how you append to a file:
    [CODE=python]output = open("some_file .txt", "a")
    output.write("h ello world\n")
    output.close()[/CODE]...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to Log in and password
    The main problem I notice with your code is that you are trying to compare a string and an integer in your IF statements. The "raw_input" function returns a string, so you must either compare strings or cast the "username" as in integer.

    This might point you in the right direction:
    [CODE=python]
    import sys

    username= raw_input('User name for this program : ')

    if username == '23':...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to explanation for recursion problem
    3 is the sum of all of the leaf nodes of the tree....
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to explanation for recursion problem
    The "cal(n-1)" in the return statement always happens first because it's farther to the left, and each of their "cal(n-1)"'s happen first.
    [CODE=python]n = 4 # it is because I use parameter 4
    n = 3 # cal(n-1), n=4-1
    n = 2 # cal(cal(n-1)-1), n=4-1-1
    n = 1 # cal(cal(cal(n-1)-1)-1), n=4-1-1-1
    n = 0
    n = 1
    n = 2
    n = 1
    n = 0[/CODE]
    Sometimes it helps to visualize...
    See more | Go to post

    Leave a comment:


  • It looks like the dictionary "b" in class "A" is shared with every instance of class "A". I don't know the exact reason for this, but it might have something to do with the items in the dictionary being stored by reference. To fix your problem, modify class "A".
    [CODE=python]class A:

    aName = ""

    def __init__(self):
    self.b = {}
    ...
    See more | Go to post

    Leave a comment:


  • I have never encountered that error before. The only thing I could find online that seemed related was this page. It looks like the author got the same error as you did on your notebook. Sorry I cannot be of more help.
    See more | Go to post

    Leave a comment:


  • Also, make sure you are trying to run "fatture\distfatture\fatture.exe" not "fatture\buildfatture\fatture.exe"
    See more | Go to post

    Leave a comment:


  • Have you tried making the spec file without the -w and --noconsole options? If it works without them, try just using one or the other. -w and --noconsole do the same thing, so maybe using them both messes up the compiler.
    See more | Go to post

    Leave a comment:


  • Here is another way to solve your problem using bvdet's method and the csv module.

    [CODE=python]import csv
    rows = csv.reader(open ("file.csv", "rb"))
    newrows = []
    for row in rows:
    if row not in newrows:
    newrows.append( row)
    writer = csv.writer(open ("file.csv", "wb"))
    writer.writerow s(newrows)[/CODE]
    See more | Go to post

    Leave a comment:


  • If the order of the information in your csv file doesn't matter, you could put each line of the file into a list, convert the list into a set, and then write the list back into the file. When you convert the list to a set, all duplicate elements disappear.

    [CODE=python]reader = open("file.csv" , "r")
    lines = reader.read().s plit("\n")
    reader.close()

    writer = open("file.csv" ,...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to implementing a calendar class
    Or even better:
    [CODE=python]>>> dateA.strftime( "%B %d, %Y")
    'May 14, 2007'[/CODE]
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to implementing a calendar class
    Or this:
    [CODE=python]>>> dateA = datetime.date(2 007, 5, 4)
    >>> output = dateA.ctime().r eplace(" ", " ").split(" ")
    >>> print "%s %s, %s" % (output[1], output[2], output[4])
    May 4, 2007[/CODE]
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to implementing a calendar class
    To format the output, try something like this:
    [CODE=python]>>> import datetime
    >>> months = ["January", "February", "March", "April", "May", "June", "July", "August", "September" , "October", "November", "December"]
    >>> dateA = datetime.date(2 007, 5, 4)
    >>> print "%s...
    See more | Go to post
    Last edited by KaezarRex; Nov 14 '07, 04:46 PM. Reason: fixed code

    Leave a comment:


  • The only way I've been able to get output from os.system is to use ">" in the command to make the subshell write its output to a file. Then all I have to do is read the file.
    [CODE=python]>>> os.system("echo hello > output.txt")
    0
    >>> reader = open("output.tx t")
    >>> print reader.read()
    hello [/CODE]
    If you want to just append to the file instead...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to derivative and newton raphson
    Here's what I have come up with:
    import math
    [CODE=python]def derivative (f, x, h):
    return float((f(x + h) - f(x))) / h

    def solve(f, x0, h, depth):
    if depth > 0:
    delta = f(x0) / derivative(f, x0, h)
    return solve(f, x0 - delta, h, depth - 1)
    else:
    return x0[/CODE]
    I changed the formulas in your function to ones I'm more familiar with, and I had to add the parameter...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to Tkinter problem with loops
    Try using this statement whenever you want to show the output:
    [CODE=python]root.update()[/CODE]...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to Geometrical mean
    Nice! I knew there had to be a way to use reduce, but I have never used lambda before. Thanks for the example....
    See more | Go to post

    Leave a comment:


  • The only way that I've been able to hide the console window was to use PyInstaller to convert my python script into an executable. It has an option to keep the console from opening when you run the program (and many other options, like packing everything into a single file). This is probably not the kind of solution you are looking for, but maybe you can use it as a last resort if it's necessary that there's no console window.
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to help with append and delete
    That looks great. Here's what I had originally thought you could do for the delete function, but once again, either way works perfectly fine.
    [CODE=python]def delete(ID):
    global database, Current_ID
    for record in range(1,len(dat abase),1):
    if database[record][1]==ID:
    database.pop(re cord)
    break #only saves time if your database is huge
    raw_input("pres s...
    See more | Go to post

    Leave a comment:


  • KaezarRex
    replied to Geometrical mean
    I hate to be a stickler on math, but the geometric mean of [1, 2, 3, 4] is (1*2*3*4)^(1/4)
    [CODE=python]def geomean(numbers ):
    product = 1
    for n in numbers:
    product *= n
    return product ** (1.0/len(numbers))[/CODE]...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...