woooee 814 Nearly a Posting Maven

I would strongly suggest that you print "p" to see what it contains and then look at what you are sending to the function

for p in primes:
    if n % p == 0:
        return False
woooee 814 Nearly a Posting Maven

set a StringVar or IntVar in the command callback, "get" example here but set works the same way. Start at "This example creates an Entry widget, and a Button that prints the current contents:"

woooee 814 Nearly a Posting Maven

999 can't stop your program because of

elif grade > 101:

Try using (but it still errors if a non-number/letter is entered)

grade = -1
while grade != 999:
    grade = int(input('Enter a grade that is greater than zero: '))
    if 0 <= grade < 101: 
        ## do calcs for a correct entry
    else:
        print "incorrect entry"
woooee 814 Nearly a Posting Maven

and Moisture for the 31 day of the month,

and Moisture for the 31 day of the month

Split the rec to isolate the date and split the date into month, day, and year.

rec="1/01/2011, 00:00, 23, 50, 2,"
split_on_space = rec.split()
print split_on_space[0]
mm, dd, ccyy = split_on_space[0].split("/")
if 31 == int(dd):
    print "Found the 31st"
else:
    print "%s is Not the 31st" % (dd)
woooee 814 Nearly a Posting Maven

I get errors on lines 3, 11, and 14 so I can't get any output to test for a float.

woooee 814 Nearly a Posting Maven

You zero the totals before the loop instead of under it

for i in range(stop1)  :
    totalgp = 0
    totalgp1 = 0

    stop = int(input('Enter the number of classes you have: '))

and you can now delete

    stop -= 1

stop1 -= 1 

since the for() loop uses a different variable, i.e. a list of numbers.

woooee 814 Nearly a Posting Maven

A simple example

class Massage_DontCallMeMessage():
    def __init__(self):
        gui = Tk()
        gui.geometry('1500x100+10+600')                 
        gui.title('ALARTS')
        gui.config (bg = 'blue')                       
        self.massage = Label(gui, text = 'this is a demo')
        self.massage.config (fg = 'white',bg = 'blue', font=('times','60'))
        self.massage.place( x = 1,y = 0,)

        self.ctr = 0
        self.change_it()
        gui.mainloop()

    def change_it(self):
        orig_text='this is a demo          '
        display_text = orig_text[-self.ctr:] + orig_text[:-self.ctr]
        self.massage["text"]=display_text
        self.ctr += 1
        if self.ctr > len(orig_text):
            self.ctr = 0
        self.massage.after(200, self.change_it)

MM = Massage_DontCallMeMessage()
woooee 814 Nearly a Posting Maven

This works per your example. However you don't have a queue.put() so you won't get anything from the get() call. I don't think that is what you want however. Look up shared data perhaps a dictionary or list would be easiest to understand depending on the size of the data. Also please try to conform to the Python Style Guide (CamelCase is for classes, lower_case_with_underscore for functions) as it makes you code easier for others to understand.

import multiprocessing as mp
import time

DELAY_SIZE = 1

def Worker(q):
    sleep_for = DELAY_SIZE / 2.0
    for ctr in range(10):       
        print "I'm working... %s"  % (ctr)
        time.sleep(sleep_for)

def Process(): 
    print "          I'm processing.."

queue = mp.Queue(maxsize=DELAY_SIZE)
p = mp.Process(target=Worker, args=(queue,))
p.start()

while p.is_alive():
  time.sleep(DELAY_SIZE)
  Process()
woooee 814 Nearly a Posting Maven

A simpler way to add up the first two numbers.

def addFirstNums(num_in):
    multBy2 = num_in*2
    y = 0
    ## convert to string and cut to two digits if more than two
    ## doesn't matter if one or more digits
    newDig = str(multBy2)[:2]
    for num in newDig:
        y += int(num)
    print num_in, multBy2, y


for num in [2, 6, 102]:
    addFirstNums(num)
woooee 814 Nearly a Posting Maven

You can not have any character, including a space, after the line continuation character "\"

print('Based on a weight of', format(package_weight, '.2f'),\ 'pounds, the shipping charge is $', format(cost, '.2f'),sep=' ')
woooee 814 Nearly a Posting Maven

I am not an expert, and this is more code than I want to wade through, so am not positive about what you are trying to do. The first part, to get the difference between numbers that occur in more than one set, is below. The program breaks the test into two separate parts, first it finds all matches and adds to a dictionary, and since I am not sure if you want everything greater than "n" or equal to, it does both.

from collections import defaultdict

def occur(lists_in):
    ## key = search number pointing to a list of numbers of 
    ## the "sets" that contain the search number
    return_dictionary = defaultdict(list)

    ## loop though each list in order using a counter to reference the list
    for outer in range(0, len(lists_in)):
        for outer_num in lists_in[outer]:
            ##loop through other lists starting with outer+1
            for inner in range(outer+1, len(lists_in)):
                if outer_num in lists_in[inner]:
                    return_dictionary[outer_num].append([outer, inner])

    return return_dictionary

list_of_lists=[['34','45','67','56'],
               ['12','71','78','20'],
               ['76','73','36','32'],
               ['34','57','67','88'],
               ['78','45','82','28'],
               ['52','10','67','41'],
               ['58','78','77','80'],
               ['57','45','68','20'],
               ['67','36','29','53'],
               ['78','79','69','21'],
               ['64','90','35','33'],
               ['45','90','52','72']]

return_dictionary = occur(list_of_lists)
n=2
for key in return_dictionary:
    for each_list in return_dictionary[key]:
        lit = ""
        dif = each_list[1] - each_list[0] ## found-original "set"
        if n+1 == dif:
            lit="skips exactly the required number"
        elif n < dif:
            lit="          skips the required number"
        print "%s occurs in %d and %d %s" % \
              (key, each_list[0], each_list[1], lit)
woooee 814 Nearly a Posting Maven

You can send a tuple to startswith

 ## note that opt is never set back to "" or "n"
 if s.startwith(('Total number of defects', 'Total charge on defect', etc.))

Are you saying that you want to stop looking after the second if s=='**** Optimisation achieved ****':

if s=='**** Optimisation achieved ****':
    if opt=='y':
        opt='n'
    else:
        opt="y"            
Gribouillis commented: I forgot about the tuple ! +14
woooee 814 Nearly a Posting Maven

Once you get to the string you want to use you can split it

new_str = '{reason:slash,data:{"""REM_1""": """=0xFF""", """REM_2""": """=0x1""", """SET0:REM_3""": """=SET2:REM_3""", """MREM_4""": """=0xFF"""};{}}'

x= new_str.split('"""')
print x[13], x[15]
print x[5], x[7]
woooee 814 Nearly a Posting Maven

That is more code than I want to trudge through for a simple question, so will just say that generally you use Toplevels as the code below illustrates. If there is more that you wish to know, post back. Note that you can use a function or third class to call (separate instance) each class as many times as you want, with individual parameters.

class one():
    def __init__(self, root):
        self.root = root
        top = tk.Toplevel(root)
        top.title("First")
        top.geometry("150x75+10+10")

        tk.Button(top, text="open new window", command=self.openit).grid()
        tk.Button(top, text="Quit", command=self.root.quit).grid(row=1)

    def openit(self):
        two = Two(self.root)

class Two():
    def __init__(self, root):
        self.root = root
        top = tk.Toplevel(root)
        top.title("Second")
        top.geometry("150x50+10+125")

        tk.Label(top, text="second window").grid()

root = tk.Tk()
root.withdraw()
one(root)
root.mainloop()
woooee 814 Nearly a Posting Maven

Whoops, indentdataion and spelling is off in the previous post (ran past 30 minutes-those interruptions!!)

Ohhhh....I would never have noticed that, thank you! (So embarrassing...)

We've all been there.

woooee 814 Nearly a Posting Maven
        Try:
            float(outputt) == float(abs(int(outputt)))
        except ValueError:
            print("Not a valid number. Please enter a valid number.")
        else:
            return float(outputt)

"try" is not capitalized

This statement does not make sense,
float(outputt) == float(abs(int(outputt)))
and there is no reason to convert to an int and then convert to a float since converting to an int removes the decimal portion of the float, and finally the return should be under the try.

def inputt(input_string):
    while True:
        outputt = raw_input(input_string):
        try:
            return float(outputt)      
            ## or better
            float_val = flaot(input_string)
            if float_val > 0:  ## won't divide by zero
                return float_val
            else:
                print("Not a valid number.")
            except ValueError:
            print("Not a valid number. Please enter a valid number.")
woooee 814 Nearly a Posting Maven

If 1000000 people drink 1 softdrink(can of 330 ml) a day, they have a carbondioxide emission of 5 x 0,33 x 1000000 = 1650000 g = 1650 kg. Any carbonated drink(beer, sprankling water, champagne, softdrink...) contains about 5 grams CO2 / liter.

Which means that all of the inventory of so far unopened containers is helping with greenhouse gasses. I'm sure the bottling companies would use this if they thought they could get away with it.

woooee 814 Nearly a Posting Maven

I watched a Western yesterday and it was one of the "caught in the desert and the horses ran off so they have to walk". Whenever someone is in a situation like this there are dried bones of creatures everywhere. How come bones never seem to be there when riding through or no one is in trouble?

On game shows a contestant says "I am married to my wife/husband". That's good as they would be a bigamist otherwise.

woooee 814 Nearly a Posting Maven

I do not know of water being used in the generation process. But perhaps that is in another type of thermal solar plant. This uses some kind of "salt" that melts when heated (I think to something like 1000 degrees F which leaves water out). The salt then heats a tank of some type of mixture that produces steam and turns a turbine, but that is a closed system meaning an extremely small amout is lost. Another advantage is that the heated salts can be stored to generate power at night.

woooee 814 Nearly a Posting Maven

There has been a solar thermal plant in the Mohave since the '80s I think and no problems with water. There aren't that many workers who are physically at the plant so a relatively small amount a water covers their drinking, bathroom, etc. requirements, but it probably has to be trucked in.

woooee 814 Nearly a Posting Maven

I am watching fewer shows because of the commercials. To watch any show you have to be willing to watch the commercials, or as I am doing more and more now, recording the show and fast-forwarding through the commercials. If a commercial contains Debbie Boone or insurance sold by the undead I turn it off. News is now more commercials than broadcast, "coming up on eye-witless news". Hopefully one day there will be pop-up blockers for TV, and I would definitely get a TV card for the computer if this ever happens. I do like some of the European mysteries like "Inspector Montalbano" though, and would possibly not watch TV at all if it were not for the few gems that do exist.

woooee 814 Nearly a Posting Maven

Those who can make you believe absurdities can make you commit atrocities.
--Voltaire

woooee 814 Nearly a Posting Maven

“The liar's punishment is, not in the least that he is not believed, but that he cannot believe anyone else.”
― George Bernard Shaw,

woooee 814 Nearly a Posting Maven

If "n" is not in the range 1-->9 it returns None (when the number entered is 10 for example). If the tens position is a "1" then it is a teens number and you would not print the ones position. Ditto for tens position when it is zero, for the numbers 100, 201 etc.

woooee 814 Nearly a Posting Maven

The first iteration of the for loop runs, but nothing else.

That is because of the "if counter > 0"

    for counter,row in enumerate(reader):
        if counter > 8: 
            continue

You also have an extra semicolon at the end of this statement

   Cur.execute("INSERT INTO vulnerabilities(IP) VALUES ('vuln_0');")

I will try to look at this again tonight and provide a working example, so post back if you get it working before that.

woooee 814 Nearly a Posting Maven

You call executemany but only supply one value. What is the point of creating the tuple "tests" or "vuln" instead of supplying the fields directly to the insert statement. You should also open or create the SQLite db once at the top of the function before the for loop. As it is, you open it on every pass through the for loop which will lead to unknown results. Take a look at this tutorial Click Here especially the "INSERT INTO Cars" examples. You have too much code here that is not tested/does not work. Start by testing each piece individually and then go on to the next piece. Post back with the snippet that does not work. Also include some test data and the version of Python, 2 or 3.

woooee 814 Nearly a Posting Maven

I would just add both directories to the PYTHONPATH variable in .bashrc. You can also add something like
export PYTHONSTARTUP=$HOME/.pythonstartup
to .bashrc to execute a given file when python starts.

Edit: Sorry, I see now from the "7" and "xp" that you are probably using a windows OS, but am going to leave the reply for any future searchers

woooee 814 Nearly a Posting Maven
woooee 814 Nearly a Posting Maven

An infinite loop as play_click is not changed within the while loop

            while(self.play_click==0):
                self.while_time()

When testing it is a good idea to limit while loops

            ctr = 0
            while self.play_click==0:
                self.while_time()
                ctr += 1
                if ctr > 99:
                    print "Counter limit exit from while loop"
                    self.play_click=99
woooee 814 Nearly a Posting Maven

That comes out to June 10th, 14 days off. There would be something like 28 leap years which is too far off to be a possibility. "41401,250002" comes back as May 9th at 6:00 AM (providing January 1, 1900 is correct).

import datetime
x=datetime.datetime(1900, 1, 1, 0, 0, 0) + datetime.timedelta(days=41433.662413)
print x.year, x.month, x.day, x.hour, x.minute, x.second
woooee 814 Nearly a Posting Maven

UnicodeDecodeError: 'utf16' codec can't decode byte 0x20 in position 108: truncated data

I assume your are using Python 2.x so try something like this.
book = open_workbook(os.path.join(folder_to_import, file_to_import), coding='utf-16')

If you have unicode file names then use
l_files_to_import = os.listdir(u"/Location/DATA")

woooee 814 Nearly a Posting Maven

The old tale is true, you can balance an egg on it's end at the vernal equinox, March 20th this year. You can also balance an egg on it's end any other day of the year.

woooee 814 Nearly a Posting Maven

Always use complete names. The program is not looking in the directory that the file is located in. Also, you should be able to use a slash, /directory_name on any OS.

##-------------------------------------------------------------
## Assumes this code is now indented to run under the for() loop
##-------------------------------------------------------------
folder_to_import = '/Location/DATA'
l_files_to_import = os.listdir(folder_to_import)
for file_to_import in l_files_to_import:
    if file_to_import.endswith('.XLS'):

            column_count=10

        # Open entire workbook
        book = open_workbook(os.path.join(folder_to_import, file_to_import))
woooee 814 Nearly a Posting Maven

A class is a prototype, i.e. it is only a potential object.

class HelloWorld :

        def __init__(self):

            print("Hi")

        def talk(self ,name):

            self.nameA = name
            print("Hello", self.nameA)

HW1=HelloWorld()     ## calls the class or creates an actual instance
HW2=HelloWorld()     ## a second, separate instance

HW1.talk("Name 1")
HW2.talk("Name Two")

print HW1.nameA
print HW2.nameA
woooee 814 Nearly a Posting Maven

i wanted to use the subprocess module also but i couldn't know how to use it , and got this Error : WindowsError: [Error 2] Le fichier spécifié est introuvable

We don't know what the statment was that produced the error so can not offer any help on how to fix it. Please include the complete error message.

woooee 814 Nearly a Posting Maven

The easiest way to eat crow is while it's still warm. The colder it gets, the harder it is to swallow.

woooee 814 Nearly a Posting Maven

2nd hit on Google pyusb backend not accessible. You have to install an additional lib that pyusb depends on, and it's also on the pyusb site but the web site isn't real clear saying that you have to install one of the library dependencies. Please mark this as solved.

woooee 814 Nearly a Posting Maven

If the car is still in transit, we don't know what the speed is. If there is no traffice, it is faster. If there is a traffic jam it is slow. If the traffice is the same then the speed is the same. If the car has already arrived, it's speed is zero, as it is parked.

woooee 814 Nearly a Posting Maven

We don't have the inherited class, EventHandler, and don't know what graphics tool kit you are using, so can not offer any assistance other than to say that you don't call the function "handle" anywhere in the code posted that I can see.

woooee 814 Nearly a Posting Maven

If someone enters a wrong user name, or password, or bc, nothing happens. It should be something along the lines of

if Choice==2:
    username = ""
    while username != uname:
        username=raw_input("Login User name: ")

This is definitely a list exercise IMHO and whould be much easier with dictionaries. The point is that you want one container for everything. Then what is printed and what is used when the customer chooses something come from the same place. If you make an error entering somewhere, it may print one price and charge another. Also, when you want to make changes you should be able to change one list/dictionary/file and have it reflect everywhere. This is an example using the first two computers.

##     number, price, bar_code, qty_on_hand, description (one line per)
products_list = [
    ["i5-3570k", 218, '04353736', 5, "Intel Core i5-3570K Quad-Core",
     "Socket LGA1155, 3.4Ghz, 6MB L3", 
     "Cache, 22nm (Retail Boxed) Gen3"],
    ["i7-3970X", 1009.99, '04322575', 5, "Intel Core i7-3970X Extreme",
     "Edition Six Core Socket LGA2011", "3.5 GHz, 15MB L3 Cache"]]

##---------- print all products
##        you could use as list of lists as here as well
empty_line = "|" + " "*49 + "|"
dashes = "|" + "-"*49 +"|"

for product in products_list:
    ## print dashes and product number
    output = "|--------------------" + product[0]
    output += "-"*(50-len(output)) + "|"
    print output

    ## print price
    output = "| Price - " + str(product[1]) + "$"
    output += " "*(50-len(output)) + "|"
    print output
    print empty_line

    ## print product code …
woooee 814 Nearly a Posting Maven

Your question was already answered in this post with a demo of converting some words using a dictionary. You insist on using re which produces the undesired results, instead of a dictionary lookup. There is nothing that anyone can do to make bad code work.

woooee 814 Nearly a Posting Maven

No "/n". The data is there it's just on one r e a l l y long line.

fp=open("data.txt", "a")
fp.write(dependent_variables)
fp.close()

And it should be

fp=open("data.txt", "a")
## do the input or calcs or whatever
fp.write(dependent_variables)
## do more input and/or calcs
fp.write(dependent_variables)
## at the end of the program
fp.close()
woooee 814 Nearly a Posting Maven

You write one ('HBHB', 0xcafe, *ssd) and multiple ('HH', chunk) and then read one ('HBHB', 0xcafe, *ssd) and only one ('HH', chunk), then one ('HBHB', 0xcafe, *ssd) and one ('HH', chunk), etc. In addition to ('HBHB', 0xcafe, *ssd) write the number of items (length) written so you know how many to read.

woooee 814 Nearly a Posting Maven

Not without code as the error is possibly in the HtmlEasyPrinting function call.
HtmlEasyPrinting(name_of_print_object, parentWindow)
http://wxpython.org/docs/api/wx.html.HtmlEasyPrinting-class.html
which it appears you overwrote/replaced with a class of the same name but we can not tell without code.

HtmlEasyPrinting.PreviewText(self, self.GetHtmlText(text))

woooee 814 Nearly a Posting Maven

When you call/instantiante the class you should be including a monitor value. Someone on Chapter 15 of the book "Object-Oriented Programming in Python" should know how to call a class. Time to go back and review the basics.

woooee 814 Nearly a Posting Maven

Duplicate of this post

woooee 814 Nearly a Posting Maven

You have not declared log_size or log1_size anywhere and it appears the indentation is off under the while True, which is an infinite loop since you don't ever exit it. There is no reason from the code you posted to append to "packed" and then write each value from packed instead of just writing to the file directly. Other than that the error message is self explanatory and we of course don't know what the values of the variables are so there is no further way to help.

woooee 814 Nearly a Posting Maven

All widgets have config options, config options for the Label Click Here or Click Here Your code modified to show some other techniques.

import Tkinter as tk
from tkFileDialog import askopenfilename
import os

class En2De():
    def __init__(self):
        self.master=tk.Tk()
        self.master.geometry("+300+10")
        self.master.title('A Translater for Translating Documents From English to German')
        self.createWidgets()
        self.master.mainloop()

    def createWidgets(self):
        quitButton = tk.Button(self.master, text='Quit',
                          command=self.master.quit, bg="lightblue",
                          width=10)
        UploadButton = tk.Button(self.master,
                           text='UPLOAD FILES HERE',
                           command= self.uploadButton,
                           width=20)
        self.Label1=tk.Label(self.master)
        self.Label2 = tk.Label(self.master,text='Please Select a language:')
        self.optionlist = ('--Select--','Afrikaans','Albanian','English','French','German','Hindi','Tamil','Telugu')
        self.var=tk.StringVar()
        self.var.set(self.optionlist[0])
        self.om=tk.OptionMenu(self.master, self.var,*self.optionlist)#om=optionmenu
        #self.ConvertButton=tk.button(self, text'Convert Files',command=self.convertButton)
        #Registering it to the window
        quitButton.grid(row=4, sticky=tk.NE)
        UploadButton.grid(row=2)
        self.Label1.grid(row=3)
        self.Label2.grid(row=0)
        self.om.grid(row=1)


    def display_message(self, msg):

        def update_counter():
            lb.configure(text="%s\n %d" % (msg, self.ctr))
            self.ctr -= 1
            if self.ctr > -1:
                lb.after(1000, update_counter)
            else:
                tlv.destroy()

        tlv=tk.Toplevel(self.master, takefocus=True)
        tlv.geometry("+320+50")
        lb=tk.Label(tlv, bg="yellow")
        lb.grid()
        self.ctr = 5
        update_counter()

    def uploadButton(self):
        filename = askopenfilename(filetypes=(("Template Files","*.tplate"),("Portable Document File","*.pdf"),("Text File","*.txt"),("Word Document","*.docx"),("Word 97-2003 Document","*.doc"),("All Files","*.*")))
        if filename:
            option = self.var.get()
            if option != self.optionlist[0]:
                self.Label1.config(text=filename,
                                    fg="red", bg="white")
            else:
                self.display_message("First select a language")

Translater = En2De()
woooee 814 Nearly a Posting Maven

It is replacing every 'a" with "ein". A tutorial on using a dictionary to map from English to Spanish

## CamelCase is reserved for classes in Python
dic_word= {
    'a':'ein',
    'an':'eine',
    'able':'KOmmen',
    'about':'gegen',
    'above':'Uber',
    'absence':'Abwesenheit',
    'absent':'abwesend',
    'accent':'Betonung',
    'accept':'akzeptieren',
    'according':'nach',
    'acquainted':'kennen',
    'across':'uber'
}

for word in ["a", "able", "acquainted"]:
    print word, "-->", dic_word[word]
woooee 814 Nearly a Posting Maven

For starters you will have to load/open and read the file Post back when you have this coded (whether it works or not) with a sample of input and the output you would like.