Beat_Slayer 17 Posting Pro in Training

The connection is available till you do a db.close() I believe, but I never used MySQL.

Beat_Slayer 17 Posting Pro in Training

Like this mate?

def DelUserDlg(self, event):
    dlg = wx.MessageDialog(None, 'Are you sure you want to delete your user?',
        'Question', wx.OK | wx.CANCEL | wx.NO_DEFAULT | wx.ICON_QUESTION)
    result = dlg.ShowModal()
    dlg.destroy()
    if result == wx.ID_OK:
        self.delete_user_function()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

I think you may use the diff data with the use 'load' to alter the pixels like a array of pixels.

Nice project.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Post some code, it should be easy to try to correct.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

A example:

print item.lower()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Why the use of break or continue for the purpose??

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Can you post your full setup file?

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

Deleted the last three lines of the login.py and it works.

Your login.py only may not be written as an actual script.

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

This simple solution will work for all files on the current dir.

import os

filelist = os.listdir('')

for files in filelist:
    basename, ext = os.path.splitext(files)
    if ext == '.kml':
        f_output = open('%s-errors.txt' % basename, 'w')
        f_output.write('whatever you want')
        f_output.close()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

And how are you implementing it?

Beat_Slayer 17 Posting Pro in Training

Doesn't this work?

from login import LoginDlg
Beat_Slayer 17 Posting Pro in Training

Insert the full path to the script instead of just the 'ask.py'.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Insert the full path to the script instead of just the 'ask.py'.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

I think that definatelly it's a bad version installed.

Try to redownload and install the proper ones.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Thanks mate by the clearing up.

I wasn't really seeing it.

import time

#initial_date = '9/14/1990'
initial_date = '6/12/2007'
initial = time.mktime(time.strptime(initial_date, "%m/%d/%Y"))

#final_date = '9/17/1990'
final_date = '1/27/2008'
final = time.mktime(time.strptime(final_date, "%m/%d/%Y"))

f_in = open('stations_temp_tonyjv.csv').readlines()
f_out = open('filtered_stations_temp.csv', 'w')

f_out.write(f_in[0])

for i in range(1, len(f_in)):
    station, date, max_temp, min_temp = f_in[i].split(',')
    date = time.mktime(time.strptime(date, "%m/%d/%Y"))
    if initial <= date <= final:
        f_out.write(f_in[i])

f_out.close()

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

By your error message it appears that your values are being correctly extracted from the controls,.

The problem relys elsewhere I believe.

Beat_Slayer 17 Posting Pro in Training

You must understand the question and logics first.

And as lrh9 said, and very good, you declare classes and define their functions.

class rectangle():

    def __init__(self, coords, sizex, sizey):
        self._startx, self._starty = coords
        self._sizex = sizex
        self._sizey = sizey

    def getBottomright(self):
        print '(%s, %s)' % (self._startx + self._sizex, self._starty + self._sizey)

    def move(self, pos):
        self._startx, self._starty = pos

    def resize(self, width, height):
        self._sizex = width
        self._sizey = height

    def __str__(self):
        return '((%s, %s), (%s, %s))' % (self._startx, self._starty, self._startx + self._sizex, self._starty + self._sizey)


r = rectangle((2, 3), 5, 6)
print str(r)

"""'((2, 3), (7, 9))'"""

r.move((5, 5))
print str(r)

"""'((5, 5), (10, 11))'"""

r.resize(1,1)
print str(r)

"""'((5, 5), (6, 6))'"""

r.getBottomright()

"""(6, 6)"""

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

Probably beacuse uou only have 239 lines, and are cycling the variable that use as index to a higher number then the elements of the list.

You should count the elements and cycle between that counting.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

I get it now.

Here it is. All you need. Classes

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Any of them tonyjv?

Not even the internal print on the textbox??

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

Some code and a clear explanation of the problem you have would help.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

I've just tested, and to me they are both in real time.

import time
import wx

class Frame(wx.Frame):
    def __init__(self):

        super(Frame, self).__init__(None, -1, 'Output to widget in realtime')

        panel = wx.Panel(self, -1)
 
        sizer = wx.BoxSizer(wx.HORIZONTAL)

        btn = wx.Button(panel, -1, 'Print RT')
        text = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE|wx.TE_READONLY)
        self.text = text

        sizer.Add(btn, 0, wx.ALL, 10)
        sizer.Add(text, 1, wx.EXPAND|wx.ALL, 10)

        panel.SetSizer(sizer)

        self.Bind(wx.EVT_BUTTON, self.onbutton, btn)

    def onbutton(self, event):
        self.textoutput('Something like this?\n')
        for i in range(1, 11):
            self.textoutput('%s printed...\n' % i)
            print '%s printed...' % i
            time.sleep(1)

    def textoutput(self, text):
        self.text.AppendText(text)
 
if __name__ == '__main__':
    app = wx.PySimpleApp(redirect=True)
    frame = Frame()
    frame.Show()
    app.MainLoop()

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

Mate, I believe that all you need to do, it's to use my example of timer, and use it to call the function to voice, instead of the threading being the voice function, the thread will calll the object voice after that time.

Hope is clear enough.

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

It was a tip as I said, and you can read the lines individually as he does now.

And your code still uses my 60 GB+ RAM stick. :)

Beat_Slayer 17 Posting Pro in Training

Something like this:

app = wx.App(redirect=True)

and wx does the rest.

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

A tip:

for line in in_file.readlines():

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training
surfaceArea = 0.007184 * (weight ** .425) * (height ** .725)

If the weight is kg and the height in cm, your surfaceArea wil be in square meters.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Like this maybe. The list and sorting it makes it easy.

def main():
    diverName = raw_input('Enter divers name: ')
    degreeOfDifficulty = input('Enter degree of difficulty: ')
    scoreList = []
    for scoreCounter in range(1, 8):
        scoreList.append(input('Enter score %s: ' % scoreCounter))
    sortedScores = sorted(scoreList)
    print '\nhighscore = %s\nlowscore = %s' % (sortedScores[6], sortedScores[0])
    totalResult = 0
    for i in range(1, 6):
        totalResult += sortedScores[i]
    totalResult = totalResult * degreeOfDifficulty * 3/5
    print '\nThe final score for diver %s is %s.' % (diverName, totalResult)

    
main()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

You just need to now how much lotion you need sy square centimeter and apply to that surface.

But first, what is suposed that number to do?

def main():
    '''program to determine a persons surface area'''

    height = float (raw_input ("How tall are you (cms?) ? "))
    weight = float (raw_input ("How much do you weigh (kgs) ? "))
    surfaceArea = (weight*o.423**height*0.725)[B]0.007184[/B]
    print "Your surafce area is %0.3f sq metres" % surfaceArea

main()
Beat_Slayer 17 Posting Pro in Training

I know the thread is solved and closed, but I got a question.

How does my solution don't work?

I don't get it.

It will copy all lines in wich the date is between that range, for sure.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

It's a typo. Your missing a d here.

elif option == 2:
    remove[B]d[/B]Expence = removeExpence(totalBudget)
    totalBudget = totalBudget + removedExpence
    printOptions()
    option = input("What would you like to do? ")
Beat_Slayer 17 Posting Pro in Training

Expert Python Programming

Rapid GUI Programming with Python and Qt

My choices would go on this ones. I would choose others if iw was game related or advanced debugging.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

The 'blit' loads a image object to the window surface.

In your example 'blit' loads the 'background' image to the window starting at cordinates 0 in x and 0 in y.

screen.blit(background, (0, 0))

The second 'blit' loads the 'sprite' image to the screen, with a fixed cordinate of 100 in 'y', and uses a variable 'x' to define the cordinate on x, that is incremented by 10 every cycle.

screen.blit(sprite, (x, 100))
x += 10

Hope it helps,

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

Can you post the contents of your scripts.

I know that sometimes they seem, but the users of the forum are not wizards, so they can not guess what you have written on the scripts.

And that "solution" of copying to the python folder, is not a real solution, for sure.

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training
Beat_Slayer 17 Posting Pro in Training

CAn you show the content of your files?

Beat_Slayer 17 Posting Pro in Training

Seem's easy.

Can you post the file?

The text pasted on the thread normally does'n keep all the text characteristics.

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

I never went,

but with some sample xml and some code effort, you may get someone attracted to the conversation.

Cheers and Happy coding.

Beat_Slayer 17 Posting Pro in Training

If i understood correctly:

initial_date = '9/14/1990'
initial_month, initial_day, initial_year = initial_date.split('/')
final_date = '9/17/1990'
final_month, final_day, final_year = final_date.split('/')

f_in = open('stations_temp.csv').readlines()
f_out = open('filtered_stations_temp.csv', 'w')

f_out.write(f_in[0])

for i in range(1, len(f_in)):
    station, date, max_temp, min_temp = f_in[i].split(',')
    month, day, year = date.split('/')
    if initial_month <= month <= final_month and \
    initial_day <= day <= final_day and \
    initial_year <= year <= final_year:
        f_out.write(f_in[i])

f_out.close()

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

But for the algorith in question all the infos I got, the more precise would be the way I implemented, but we must see also that the level of accuracy of a so simple algorithm is not great.

Anyway, i also don't like the reliability of that way of stemming.

I've got a new version to be posted, where I use a implementation of a real stemmer, but the truth is that if you compare the results of the two, you will see the the method current used is very good in general.

Cheers, and thanks by the comments mate.

Happy coding

Beat_Slayer 17 Posting Pro in Training

About the patterns, I think it makes sense if you let the leaf_words private, but then it takes out the possibility of altering them and running it with different orders for testing purposes.

Beat_Slayer 17 Posting Pro in Training

I don't get the previous link.

May you take a look here, fell free to ask, or PM with sugestions.

Texts K-Nearest Neighbor (KNN) using the Euclidean algorithm

Beat_Slayer 17 Posting Pro in Training

Something like this.

name = []
ordertotal = []
for i in range(loopController):
    name.append(raw_input("Who's order"))
    order = input("How much was the order")
    ordertotal.append(order + shippingCharge)

for i in range(loopController):
    print name[i], ordertotal[i]
Beat_Slayer 17 Posting Pro in Training

No, You must have 'apple', not 'appl'.

Process - proces - proc

Beat_Slayer 17 Posting Pro in Training

Sorry but all I can say is:

You must be kidding!

Not a litle effort, just a line question?

Cheers and Happy coding

Beat_Slayer 17 Posting Pro in Training

The pattern must be done inside the loop since they are 6 different patterns.

And about the order, for all the information I could get I believe that it is right.

Beat_Slayer 17 Posting Pro in Training

-Fixed bug on the knn display.
-Improved calculation accuracy.
-Auto save and auto load of categories

import re
from math import sqrt
try:
    import cPickle as pickle
except:
    import pickle


class Words_Works():

    def __init__(self):
        self.all_texts = {}
        self.categories = {}
        self.knn_results = {}
        self.leaf_words = ['s', 'es', 'ed', 'er', 'ly', 'ing']
        self.stop_words = ['a', 'i', 'it', 'am', 'at', 'on', 'in', 'of', 'to', 'is', 'so', 'too', 'my', 'the', 'and', 'but', 'are', 'very', 'here', 'even', 'from', 'them', 'then', 'than', 'this', 'that', 'though']
        self.__load_categories()

    def __load_categories(self):
        try:
            cat_db = open('categories.pkl', 'rb')
            self.categories = pickle.load(cat_db)
            cat_db.close()
            categories = list(self.categories.keys())
            print '%s categories loaded:' % len(self.categories.keys())
            print ', '.join(self.categories.keys())
            print
        except:
            print 'No categories were loaded.\n'

    def add_category(self, f, cat_name):
        f_in = open(f)
        self.text = f_in.read().lower()
        f_in.close()
        self.__wordify()
        self.__unstopify()
        self.__unleafify()
        self.categories[cat_name] = {}        
        for item in self.unleaf:
            if self.categories[cat_name].has_key(item):
                self.categories[cat_name][item] += 1
            else:
                self.categories[cat_name][item] = 1
        self.__save_categories()

    def del_category(self, cat_name):
        if cat_name in self.categories.keys():
            del self.categories[cat_name]
        self.__save_categories()            

    def __save_categories(self):
        cat_db = open('categories.pkl', 'wb')
        pickle.dump(self.categories, cat_db, -1)
        cat_db.close()

    def add_text(self, f):
        f_in = open(f)
        self.text = f_in.read().lower()
        f_in.close()
        self.__wordify()
        self.__unstopify()
        self.__unleafify()
        self.all_texts[f] = {}        
        for item in self.unleaf:
            if self.all_texts[f].has_key(item):
                self.all_texts[f][item] += 1
            else:
                self.all_texts[f][item] = 1

    def __wordify(self):
        words_pat = re.compile('\\w+')
        self.words = words_pat.findall(self.text)

    def __unstopify(self):
        self.unstop = [item for item in self.words if item not in self.stop_words]

    def __unleafify(self):
        self.unleaf = self.unstop[:]
        for leaf in self.leaf_words:
            leaf_len = len(leaf)
            leaf_pat = re.compile('%s$' % leaf)
            for i in range(len(self.unleaf)):
                if leaf_pat.findall(self.unleaf[i]):
                    self.unleaf[i] = self.unleaf[i][:-leaf_len]

    def knn_calc(self):
        for text in self.all_texts.keys():
            self.knn_results[text] = …
Beat_Slayer 17 Posting Pro in Training

Hope it helps.

def voice(x):
    print x

v = threading.Timer(50, voice)
v.start()

Cheers and Happy codings

Beat_Slayer 17 Posting Pro in Training

Create function to voice users and run the function using the timer, instead of passing commands to the timer function.

Beat_Slayer 17 Posting Pro in Training

Some search and...

Post if you get stuck later. :)

Cheers and Happy coding