woooee 814 Nearly a Posting Maven

How about a reference for "noli mentula" which I just looked up. Good one.

Reverend Jim commented: It's the latin translation (loose) of Wil Wheaton's philosophy. +0
woooee 814 Nearly a Posting Maven

Here is a source for those who are not too lazy too look it up themselves when they want to know more www.google.com

This thread is here for fun, it's not a research paper, so believe it or not as you choose. And only the naive believe that references make it true.

woooee 814 Nearly a Posting Maven

Neither, as your logic is not at all correct. If you aren't going to take my advice, i.e. print "i", then there is not much point in posting anything further.

woooee 814 Nearly a Posting Maven

In the vein of interfacing with an alien's computer, the plot of the James Bond film, GoldenEye, was electronically transferring everything from the Bank of England and immediately triggering an EMT pulse that would corrupt/erase magnetic media.

But what does the criminal do then? Walk into a Bank of England branch and say "my computer says that I own everything. Start loading up the trucks (I mean lorries)". The bank cleark would say "Excuse me while I check one of our hundred other branches worldwide, and then we will confirm via our backup on those new fangled CDs, which use a laser so weren't affected. Oh yes, our fraud department checked for fraud immediately afer the EMT incident and has reversed those transactions."

woooee 814 Nearly a Posting Maven

And by association, disk drive manufacturing and jobs.

woooee 814 Nearly a Posting Maven

What, no one has mentioned writing a sloppy, undocumented program because it is a one-time quick and dirty use. Murphy's law says you will still be using that program 10 years from now and it will be much, much longer.

minitauros commented: My god.. so true +0
woooee 814 Nearly a Posting Maven

grid() returns None so self.label1 equals None in the code you posted.

There are two ways to update a label, illustrated below. There is way too much code here for me to traverse so the following is independent of any code you posted.

class UpdateLabel():
    def __init__(self):
        self.master = tk.Tk()
        self.label1_text = tk.StringVar()
        self.label1_text.set("initial value")
        self.label1=tk.Label(self.master, textvariable=self.label1_text,
                            fg='blue', font=("Arial", 36, "bold"),
                            background='#CDC5D9')
        self.label1.grid(row=0,column=0)

        self.master.grid_columnconfigure(1, minsize=100)

        self.label2=tk.Label(self.master,text='Initial value',
                            fg='blue', font=("Arial", 36, "bold"),
                            background='#CDC5D9')
        self.label2.grid(row=0,column=2)

        tk.Button(self.master, text="Quit", command=self.master.quit,
                  bg="red").grid(row=1, column=0)

        ## update the label in two different ways
        self.master.after(2000, self.update_label_1) ## sleep for 2 seconds

        self.master.mainloop()

    def update_label_1(self):
        ## update label1 by changing the StringVar()
        self.label1_text.set("2nd value")
        self.label1.config(bg="yellow")


        ## update label2 by setting the text
        self.label2["text"] = "third value"
        self.label2["fg"] = "green"
        ## this is the same as the above line
        ##self.label2.config(text="third value")

UpdateLabel()
Gribouillis commented: good help +14
woooee 814 Nearly a Posting Maven

Start here with your post Click Here

woooee 814 Nearly a Posting Maven

You would use a list of lists. One sub-list for each row, so if the data is 1, 3, 2, 7, 5 and you are drawing the third row, you would place an "X" in the element at offsets 1,3, and 4 since those 3 all require a third row. Once that is done you can just join and/or print each sublist.

woooee 814 Nearly a Posting Maven

I've tried a 'for i in range(53):'loop but
that doesn't work for this

Why not? It seems like the proper way to do this. Note that you salt the variables with the first 2 numbers, so the loop would run 2 less than the number of the total sequence.

Also, do not use i, O, l, etc. as variable names as they look like numbers, i.e. k+l, is that k+el or k+one?

a =  23
b = 7
c = 18

print 1, b
print 2, c
for ctr in range(a-2):
    b, c = c, b+c
    print ctr+3, c
woooee 814 Nearly a Posting Maven

Write program to run some test code in parallel and use a while loop to check is_alive() for each process and/or a manager dictionary that is updated when the function/thread finishes.

def process_status(list_of_ids):
    while True:
        done = True
        for pid in list_of_ids:
            if pid.is_alive():
                done = False

        if done:
            return
        time.sleep(0.1)  ## don't hog the processor
woooee 814 Nearly a Posting Maven
  1. Hypocrisy
    When the Way is forgotten
    Duty and justice appear;
    Then knowledge and wisdom are born
    Along with hypocrisy.

    When harmonious relationships dissolve
    Then respect and devotion arise;
    When a nation falls to chaos
    Then loyalty and patriotism are born.

    TaoDeChing - Lao Tze

woooee 814 Nearly a Posting Maven

Saw this one one the web so I guess it's a quote

A gaggle of geese
A murder of crows
A bribe of politicians

woooee 814 Nearly a Posting Maven

The docs are always a good place to start Click Here Strftime is part of the datetime.date class, not datetime.datetime.

woooee 814 Nearly a Posting Maven

The Xerox Palo Alto Research Center, known as Xerox PARC, developed the graphical user interface (GUI), laser printing, WYSIWYG text editors, and Ethernet. And perhaps more importantly developed object oriented programming.

woooee 814 Nearly a Posting Maven

This certainly sounds like homework, i.e. lists must be used. Another way is to sort the list first and then count.

original_list = ["hello", "hi", "hi", "bye", "hi", "bye"]
original_list.sort()
counter_list = []
ctr = 0
previous = original_list[0]
for word in original_list:
    if word != previous:
        counter_list.append([previous, ctr])
        ctr = 0
        previous = word
    ctr += 1

counter_list.append([word, ctr])
print counter_list
woooee 814 Nearly a Posting Maven

Cross posted so may have already been answered. Check first so you don't waste your time.
http://qt-project.org/forums/viewthread/46750
http://bytes.com/topic/python/answers/958375-how-check-signal-emit-finished-python

woooee 814 Nearly a Posting Maven

What does it do differently than what you expect? A simple example with an explanation of what you want will get faster and better results

Note that encode_files is declared twice and there are indentation errors in the code.

woooee 814 Nearly a Posting Maven

Please post the entire error message as we have no idea where it may be coming from. The call to encode_files, may be the problem but that code is not included so we can't tell..

woooee 814 Nearly a Posting Maven

I would suggest that you first write it out on paper with 2 or 3 actual examples of what you want and then see how the program differs from the actual examples. For example, balance and remaining balance never change, why? How would you keep track of remaining balance when doing it by hand?

woooee 814 Nearly a Posting Maven

It is a good idea to strip() a record first, unless you are really really sure of the format.

Lambda is a bad habit IMHO. Guido wanted to omit lambda (and map, reduce, & filter) from Python3 because list comprehension is faster and the code is easier to understand. So form the habit of using list comprehension, or partial when you want to pass arguments to a function.

woooee 814 Nearly a Posting Maven

This code from Vegaseat tells you which key is pressed. You can use a similar function that tests for cetain keys and responds accordingly. I think the general binding is

widget.bind("<1>", call_back) (for the number 1).

try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x

def key_in(event):
    ##shows key or tk code for the key
    if event.keysym == 'Escape':
        root.quit()
    if event.char == event.keysym:
        # normal number and letter characters
        label_str.set('Normal Key ' + event.char)
    elif len(event.char) == 1:
        # charcters like []/.,><#$ also Return and ctrl/key
        label_str.set('Punctuation Key %r (%r)' % (event.keysym, event.char) )
    else:
        # everything else
        # F1 to F12, shift keys, caps lock, Home, End, Delete, Arrows ...
        label_str.set('Special Key %r' % (event.keysym))

root = tk.Tk()
label_str=tk.StringVar()
label_str.set(" ")
tk.Label(root,textvariable=label_str, fg="blue").grid()
tk.Label(root, text="Press a key (Escape key to exit):" ).grid(row=1)

ent=tk.Entry(root)
##ent.grid(row=0, column=1)   ##Not packed so will take any entry
ent.bind_all('<Key>', key_in)
ent.focus_set()

root.mainloop()
woooee 814 Nearly a Posting Maven
while not (done):

will loop until done==True
To get done==True in the code you posted, you have have to enter "s" on your only input line, i.e.

    choose=input("\nChoose a class please : f=Fighter, m=Magic User ")

You can also use a return statement to exit the funtion containing the while loop

woooee 814 Nearly a Posting Maven

"Aligning" depends also on the font used. If you are displaying the result in the console, then the console must use a fixed witdth font. If you want to experiment, save the result to a file, open the file with any text/word processor and change the font from proportional to fixed width.

Gribouillis commented: very good! +14
woooee 814 Nearly a Posting Maven

That tells you nothing. You have to print it on the line before the error message on every pass through the for loop so you know where and what the error is.

woooee 814 Nearly a Posting Maven

If channelList has less than seven entries then you will get an error on channelList[index]. You will have to print channelList and/or len(channelList) to see where the error is.

woooee 814 Nearly a Posting Maven

We don't know which one of at least 3 or 4 possible statements is causing the error because you did not include the error message. As a shot in the dark I would suggest that you print row or cur or both somewhere around this for() statement

   cur.execute('SELECT channel FROM programs WHERE channel GROUP BY channel')

   for row in cur:

This is a link to an SQLite tutorial but should be OK for whatever SQL engine you are using
http://zetcode.com/db/sqlitepythontutorial/

woooee 814 Nearly a Posting Maven

You have to use the get() method of the StringVar. See the second, or get() example at Click Here i.e convert from a Tkinter variable to a Python variable

woooee 814 Nearly a Posting Maven

You would use partial. I don't have Qt installed so can't test, but this should work. Note that if it is self.thrown error, you don't have to pass it to the function as "self" variables can be accessed anywhere within the class.

from PyQt4.QtCore import pyqtSignal, pyqtSlot
from PyQt4.QtGui import QWidget, QApplication
from PyQt4 import QtCore
import sys
from functools import partial

_qObject = QtCore.QObject()

has_error = pyqtSignal(Exception)

class SomeOtherClass(QWidget):

    # this is my UI class

    def __init__(self, parent=None):
        super(SomeOtherClass, self).__init__(parent)

        # Initialise the Class and connect signal to slot
        QtCore.QObject.connect(_qObject, partial(has_error, self.thrown_error))


    @pyqtSlot(Exception)
    def thrown_error(self, my_err):
        #Do Stuff with the Exception
        print(type(my_err), my_err)
        self.close()


def makeError():
    try:
        print 1/0
    except ZeroDivisionError, ze:
        has_error.emit(ze)

makeError()

app = QApplication(sys.argv)
SomeOtherClass()
woooee 814 Nearly a Posting Maven

You find the location in the line and then seek in the file using the location found in some unknown line. Choose either the line or the file, for example:

## the following "while" line will exit when artist_string is found
## and so the rest of the code (seek_position, etc.)
## will never be executed
##while artist_string not in line:
##    line = f.readline()

for line in f:
    if artist_string in line:
        seek_position = line.find(artist_string)
        print line[seek_position:]
        break
woooee 814 Nearly a Posting Maven

There is no problem with the entry boxes as the code below will show, i.e. name and password are printed correctly. The problem is verifying the input and "passwords" is not defined anywhere in the code you posted so we have no way to know what you are using to check the input against.

from tkinter import *

# Create the window
root = Tk()
root.title("NEOSA Corp Interface")

# Background
##p = PhotoImage(file="CIA.gif")  ## we don't have this image
l = Label(root)

# Password for main screen

e = Entry(l, show="*", width=30)
e.pack(side=TOP, anchor=W, padx=450, pady=300)
e.focus()

######################################################

# Fail entery

def make_entry(parent, caption, width=None, **options):
    Label(parent, text=caption).pack(side=TOP)
    entry = Entry(parent, **options)
    if width:
        entry.config(width=width)
    entry.pack(side=TOP, padx=10, fill=BOTH)
    return entry

def enter(event):
    check_password()

def check_password(failures=[]):
    """ Collect 1's for every failure and quit program in case of failure_max failures """
    print(user.get(), password.get())
    """
    *****  commented because we don't have "passwords"
    if (user.get(), password.get()) in passwords:
        root.destroy()
        print('Logged in')
        return
    failures.append(1)
    if sum(failures) >= failure_max:
        root.destroy()
        raise SystemExit('Unauthorized login attempt')
    else:
        root.title('Try again. Attempt %i/%i' % (sum(failures)+1, failure_max))
    """


#frame for window margin
parent = Frame(root, padx=10, pady=10)
parent.pack(fill=BOTH, expand=True)
#entrys with not shown text
user = make_entry(parent, "User name:", 16, show='')
password = make_entry(parent, "Password:", 16, show="*")
#button to attempt to login
b = Button(parent, borderwidth=4, text="Login", width=10,
           pady=8, command=check_password)
b.pack(side=BOTTOM)
password.bind('<Return>', enter)

user.focus_set()
###########################################################################

# Main Screen Shut Down

b = Button(l, command=quit, text="Shut Down")
b.pack(side=BOTTOM, expand=Y, anchor=S)


l.pack_propagate(0)
l.pack()


root.mainloop()

root = Tk()

# Modify root window …
woooee 814 Nearly a Posting Maven

The smallest time displayed is seconds. The function is called every 2/10 of a second, so the clock is not updated if the time to the second has not changed.

woooee 814 Nearly a Posting Maven

"ans" is never changed under the "while ans" loop so it loops continuously. A function Click Here would make things easier and cleaner

def get_numbers(number_to_get):
    return_list = []
    lits = ["first", "second", "third", "fourth", "fifth"]
    for num in range(number_to_get):
        input_num = raw_input("enter your %s number " %(lits[num] ))
        return_list.append(input_num)
    return return_list

ans=raw_input("""
Thanks for choosing addition mode!  
How many numbers would you like to add? """)
numbers_list = get_numbers(int(ans))
print numbers_list
woooee 814 Nearly a Posting Maven

There is more than one way to skin that cat. I use a tkinter variable and update it. Note that you have to call updater() to get the whole thing started.

try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x

class UpdateLabel():
    def __init__(self):
        self.win = tk.Tk()
        self.win.title("Ausgangsposition")
        self.win.minsize(800, 600)
        self.ctr = 0
        self.tk_var = tk.StringVar()
        self.tk_var.set("0")
        lab=tk.Label(self.win, textvariable=self.tk_var,
                       bg='#40E0D0', fg='#FF0000')
        lab.place(x=20, y=30)
        self.updater()
        self.win.mainloop()

    def updater(self):
        self.ctr += 1
        self.tk_var.set(str(self.ctr))
        if self.ctr < 10:
            self.win.after(1000, self.updater)
        else:
            self.win.quit()

UL=UpdateLabel()
woooee 814 Nearly a Posting Maven

The response was to your first error message.

win" is closed but cmd shows error logs every 5 seconds because of the label in "getcurrentrateandcurrentbalance()".
Any idea how to fix this? The methode seems to be called again although "win" is closed.

It was still running because Tk was still running. Your function calls itself repeatedly

def getcurrentrateandcurrentbalance():
    threading.Timer(5.0, getcurrentrateandcurrentbalance).start()

What is it you are trying to do? And why does creating a label require Threading and Timer? It is better to use Tkinter's after() and update() if necessary to call a funcion every x seconds. Click Here

Your next error will be because of an undeclared variable (at least in the code you posted).

print "Hello, World!" + result

"result" if not declared or updated in the function.

woooee 814 Nearly a Posting Maven

The button's command parameter http://effbot.org/tkinterbook/button.htm would call a funtion that would open a new Toplevel Gui http://effbot.org/tkinterbook/toplevel.htm

woooee 814 Nearly a Posting Maven

A guess would be that "newSentence" is used in both loops so contains only the value from the last loop. Or in
number = len(sentence)
"sentence" is not initialized and still has a length of zero.
Convert this code to a function and pass each player's correct-letters-guessed list and the to be guessed word to the function, returning the new list. Note that "in enteredLetters" should not be necessary as "in newSentence" will give the same result. For further assistance be more specific about what "it doesn't work" means.

woooee 814 Nearly a Posting Maven

You use the variable name "blue" in two different places.

woooee 814 Nearly a Posting Maven

This gets the directory name and has nothing to do with file name. TKinter has an askopenfilename method to get the file names.

woooee 814 Nearly a Posting Maven

but how do I make it more of an arbitrary path (rather than the C:\Users etc) since I need it so that anyone can run that program and write to that file.

Tkinter has an askdirectory Click Here

woooee 814 Nearly a Posting Maven

Do you want to include numbers and everything else not in string.punctuation

s_nopunct = "".join(c for c in s if c not in string.punctuation).lower()

Generally it is better to include what you want instead of excluding a certain set as above, as anything you forgot about is automatically included.

s_nopunct = "".join(c for c in s if c in string.letters).lower()

A set intersection of string.letters and "s" can also be used.

Note also that list_unique is only one name as you have it in the code above so the

for x in list_unique:

is not necessary.

kxjakkk commented: I only want to include words that are 2 or more letters. Words such as "error-free" would need to be separated to form just two words. +0
woooee 814 Nearly a Posting Maven

Use a function http://www.tutorialspoint.com/python/python_functions.htm and call it as many times as you like

import time

def print_something(ctr):
    choices = ["zero", "one", "two", "three", "four",
               "five", "six"]
    if ctr < len(choices):
        print(" This is page", choices[ctr])
    else:
        print("Sorry, but what you have typed in is invalid,\nPlease try again.")

ctr=1
print_something(ctr)
time.sleep(1.0)
ctr = 6
print_something(ctr)
time.sleep(1.0)
ctr = 10
print_something(ctr)
woooee 814 Nearly a Posting Maven

Conundrum = Trying to fiqure out what Pneumonoultramicroscopicsilicovolcanoconiosis means

woooee 814 Nearly a Posting Maven

Yes, and I wonder how many answer wrong on purpose, thinking that's a dumb question.

woooee 814 Nearly a Posting Maven

The problem is here

while os.stat(filename).st_size < size:

Both input and output are buffered on computers. First create a list of what you want to write and check the size each time. Then use .join() to write the file. Writing each number to the file is inefficient and slower anyway, so keep the data in memory where you have more control.

Also, Python has universal newline support so you can just use "\n".

woooee 814 Nearly a Posting Maven

Sleep showers away cellular grime that builds up while the brain is awake. The brain pushes fluid in between its cells to flush out buildup products, such as protein pieces that form plaque in people with Alzheimer's disease.
Science News Magazine

woooee 814 Nearly a Posting Maven

Your code is not anything that can really be corrected. Start with the "Defining Classes" and "Using Classes" Click Here and go on from there Post back once you have the basics down with any further questions.

woooee 814 Nearly a Posting Maven

"I love it when a plan comes together." - John "Hannibal" Smith (The A-Team)

+1

I am, therefore I think. Descartes has it backwards.

woooee 814 Nearly a Posting Maven

Traceback (most recent call last):
File "C:UserslinuxDesktopscreenshot1.py", line 11, in <module>
img.save(SAVE_PATH)

Print SAVE_PATH to see what name the program is trying to use (not the one you think it is). Also you can use
from os import environ
My computer likes environ['HOME'] instead of 'HOMEPATH' but it may be different on different OS's.

Gribouillis commented: good +14
woooee 814 Nearly a Posting Maven

Using partial is easier and makes more sense IMHO Partial examples

from functools import partial

...

## to send "on" and "host" to callback_power_on function
b = Button(master,
           text="Power On",
           command=partial(callback_power_on, on, host))  

##---------- or if you prefer  ----------------------------
b = Button(master,
           text="Power On",
           command=partial(callback_power_on, data=on, host=host))