Forum: Python 7 Hours Ago |
| Replies: 5 Views: 116 The problem might be the double "input" on the previous line. You did not state that there was an error in the first post, and to get any more help you will have to post the exact error message as... |
Forum: Python 7 Hours Ago |
| Replies: 5 Views: 116 if option==3:
active<>"on"This will print "True" if active != 'on' and print "False" otherwise. <> has been deprecated so use "!=" instead. I think you want if option==3:
... |
Forum: Python 2 Days Ago |
| Replies: 3 Views: 158 First you want to check that the word ends up as an even number, otherwise you can't divide it in two. Tiger = 59 so is not a good choice. import string
def number_equiv(word):
## I prefer... |
Forum: Python 5 Days Ago |
| Replies: 7 Views: 340 There is also pyMouse http://code.google.com/p/pymouse/
There is this example for xlib
http://ltool.svn.sourceforge.net/viewvc/ltool/trunk/LtMacroAPI.py?view=markup
I have only used curses for... |
Forum: Python 5 Days Ago |
| Replies: 7 Views: 340 The system calls would be different on Windows so the code would differ too much to make it practical. There probably is something similar but something for MS Windows with a Python wrapper as well... |
Forum: Python 5 Days Ago |
| Replies: 7 Views: 340 It should be something with ButtonReleaseMask. Try this code and Google for ButtonReleaseMask if it doesn't work.
import Xlib
import Xlib.display
display = Xlib.display.Display(':0')
root =... |
Forum: Python 8 Days Ago |
| Replies: 6 Views: 224 Just read it, line by line, as a normal file, unless it is not a text file, in which case you would have to read and convert to text. See 2.4.5 here... |
Forum: Python 8 Days Ago |
| Replies: 4 Views: 277 You have to enter "d:\" to make it equal to "d:\\" since backslash is the escape character. Why not make it simple and test for "D:" only. I've added some print statements to clarify. ... |
Forum: Python 8 Days Ago |
| Replies: 6 Views: 224 It's pretty straight forward, and since I'm sick and not doing much today... test_data = [ "c The random seed used to shuffle this instance was seed=1755086696",
"p cnf 1200 4919",
... |
Forum: Python 11 Days Ago |
| Replies: 4 Views: 201 test_matrix = [ ["A", "b", "c"], \
["R", "S", "s"], \
["X", "Y", "Z"] ]
for sublist in test_matrix:
print sublist
for ch in sublist:
if ch == "S":
... |
Forum: Python 12 Days Ago |
| Replies: 8 Views: 307 This statement will never be true
elif (data[x]>57 and data[x]<48): |
Forum: Python 14 Days Ago |
| Replies: 4 Views: 376 This is an example I had using QLineEdit and QTextEdit. There are other ways to retrieve text based on starting and ending positions but I don't use it. import sys
from PyQt4 import QtGui, QtCore... |
Forum: Python 16 Days Ago |
| Replies: 4 Views: 274 Numpy will probably already do everything you want http://www.scipy.org/Tentative_NumPy_Tutorial#head-926a6c9b68b752eed8a330636c41829e6358b1d3 |
Forum: Python 16 Days Ago |
| Replies: 2 Views: 178 You can use a dictionary as a counter, but you first have to convert the key to a tuple. arr=[[10, 2, 10],
[10, 9, 10],
[10, 9, 10],
[10, 9, 10],
[10, 9, 10],
[22, 9, 10],
[10, 9, 10],
[10, 9,... |
Forum: Python 17 Days Ago |
| Replies: 3 Views: 239 First, try running this code in Idle. It will tell you that there are problems with this statement with a variable name that contains special characters.... |
Forum: Python 17 Days Ago |
| Replies: 10 Views: 337 Why do want to import the same thing a second time? You already have it in memory. Putting the same thing in another block of memory is a waste.
To test for a number, there are several ways to... |
Forum: Python 18 Days Ago |
| Replies: 3 Views: 214 The first two posts found in a search of this forum, after your post which is the first/latest, have working solutions that you should be able to adapt. |
Forum: Python 22 Days Ago |
| Replies: 4 Views: 376 The short answer is to look at QLineEdit here http://www.devshed.com/c/a/Python/PyQT-Input-Widgets/ More tutorials are on the wiki http://www.diotavelli.net/PyQtWiki/Tutorials |
Forum: Python 22 Days Ago |
| Replies: 15 Views: 518 I don't think that anyone here is going to give you code that you can take to another forum, claim it is yours, and ask them to finish it for you. Let this thread die. |
Forum: Python 24 Days Ago |
| Replies: 15 Views: 518 Start by asking the player(s) for a name and store it in a dictionary that will also keep track of their score. Then, open one graphic window that will simply display the name and score of the... |
Forum: Python 26 Days Ago |
| Replies: 10 Views: 555 if "EMERGENCY" or "Help" or "!" in heading:
pass
elif ("no idea" in body) or (not Code() in body):
pass |
Forum: Python 27 Days Ago |
| Replies: 2 Views: 450 I think you could check for a number in the second position, if I understand correctly that overlays use numbers and updates/adds use a letter. if len(line.strip()) and \
not... |
Forum: Python 27 Days Ago |
| Replies: 3 Views: 338 So you are obviously using PyQT4 built for Python 2.6. The error message confirms it. Ask how to install PyQT for both 2.6 and 3.x on the Ubuntu or PyQt forum. Some one has done this and if there... |
Forum: Python 29 Days Ago |
| Replies: 4 Views: 337 Python does not have static variables, but does have global variables, which those are not. They are class objects and would be called using
Atom.cartesian
both inside and outside the class. In... |
Forum: Python 30 Days Ago |
| Replies: 4 Views: 337 You have both class instances and class objects. The variables
cartesian = dict()
bondList = list()
atomName = str()
atomicNum = int()
would point to the same variable (block... |
Forum: Python 30 Days Ago |
| Replies: 6 Views: 344 That's called string formatting http://www.python.org/doc/2.5.2/lib/typesseq-strings.html (assuming you are using Python 2.5). A simple example: year = 1
pop = 12345
for x in range(2):
print... |
Forum: Python Nov 13th, 2009 |
| Replies: 16 Views: 465 Agreed. You should do your own research from here. Especially since you are just going to forget most of this anyway. Herb Schildt was the consensus guru when this was commonly done, so if you can... |
Forum: Python Nov 12th, 2009 |
| Replies: 16 Views: 465 If you wanted to draw a box on the screen and display some sort of message, you would have to access the memory on the video card. Before toolkits like Tkinter that is the way it was done. In... |
Forum: Python Nov 8th, 2009 |
| Replies: 7 Views: 236 Try this and then go to the page from the earlier link which explains why you returned a tuple. def junk(f):
d1 = {}
d2 = {}
for line in f:
columns = line.split(":")
... |
Forum: Python Nov 8th, 2009 |
| Replies: 7 Views: 236 First you are not returning a dictionary. I've added a print statement to show that. Also, take a look at "returns" and "arguments" here http://www.penzilla.net/tutorials/python/functions/ for the... |
Forum: Python Nov 8th, 2009 |
| Replies: 2 Views: 360 It is generally done with a list. def test_input(input_str):
accept_list = []
for x in range(0, 10):
accept_list.append(str(x))
accept_list.append("d")
accept_list.append("r")... |
Forum: Python Nov 7th, 2009 |
| Replies: 5 Views: 615 It should be simple with Python's gstreamer interface. http://pygstdocs.berlios.de/ |
Forum: Python Nov 7th, 2009 |
| Replies: 16 Views: 493 Not enough info for anyone to help (could be an indentation error, or could be in the calcs). First add some print statements for the individual calcs to isolate the error, and post the specific... |
Forum: Python Nov 6th, 2009 |
| Replies: 8 Views: 305 finderGuess = finderGuess - ((((finderGuess*((1+finderGuess)^numberMonths))/(((1+finderGuess)^numberMonths)-1))-
(monthlyPayment/loanAmount))/(((((1+finderGuess)^numberMonths)-1)
... |
Forum: Python Nov 6th, 2009 |
| Replies: 9 Views: 835 There are several online pages to do that.
http://primes.utm.edu/curios/includes/primetest.php
is one found on this very good page
http://primes.utm.edu/
Your program works correctly, at least... |
Forum: Python Nov 5th, 2009 |
| Replies: 9 Views: 270 All data is binary. That's the way the computer does it. I am assuming that you mean bytes that are not text. If you look at an ASCII table like this one http://www.asciitable.com/ it becomes... |
Forum: Python Nov 3rd, 2009 |
| Replies: 9 Views: 835 Wouldn't this lead to an infinite loop. def Prime(x,y):
n=2
if x == 1:
Prime(x+1,y)
elif x == 2:
print (2)
Prime(x+1,y)
elif x <= 0:
print ("Number must... |
Forum: Python Nov 2nd, 2009 |
| Replies: 8 Views: 240 You want to use "readlines()",as readline reads one line at a time, where readlines() reads all data. Also, a print statement is added for clarity.records = open(grades.txt,'r').readlines()
table =... |
Forum: Python Nov 1st, 2009 |
| Replies: 3 Views: 265 And it's not tough to do. import Tkinter
root = Tkinter.Tk()
root.title('Canvas')
canvas = Tkinter.Canvas(root, width=450, height=450)
canvas.create_oval(100,50,150,100, fill='gray90')
x =... |
Forum: Python Oct 30th, 2009 |
| Replies: 4 Views: 250 This is very simple to do. print len(set([1,2,4,2,7])) |