2,190 Posted Topics

Member Avatar for DragonSlayerX

[QUOTE=;][/QUOTE] Comment the Circle and Box lines and see if you get a line. Then figure out why only Line() works. [code]from gasp import * begin_graphics() #Circle((200, 200), 60) Line((100, 400), (580, 200)) #Box((400, 350), 120, 100) update_when('key_pressed') end_graphics() [/code]

Member Avatar for DragonSlayerX
0
104
Member Avatar for JoshuaBurleson

[QUOTE=;][/QUOTE] For storing a few values, like phone number and e-mail address, you can use a list which is easier to understand and use. [code]AB={'Joshua' : ['sho0uk0m0o@gmail.com', '(802) 3-5-2206'], 'Ashley': ['a000@gmail.com', '(802) 820-0000']} print "%s, e-mail=%s, phone=%s" % ("Joshua", AB["Joshua"][0], AB["Joshua"][1]) new_name = "Bill" new_email= "bill@domain.com" new_phone= "(802) 123-4567" AB[new_name] …

Member Avatar for JoshuaBurleson
0
299
Member Avatar for miac09

[QUOTE=;][/QUOTE] At some point you will have to use a list to store multiple values. This is something along the lines of what I think you want. [code]lista = [(3015, 3701), (4011, 5890), (10,40), (150,300)] listb = [(3045, 3800), (1,2), (100,200), (4500,6000), (20,145)] def overlap(lista, listb): a=0 b=0 found_list = …

Member Avatar for TrustyTony
-1
228
Member Avatar for elieobeid7

[QUOTE=;][/QUOTE] This forum is for Python programs. I would suggest that you ask this question on a ActivePython forum, or an installing Python forum.

Member Avatar for elieobeid7
0
98
Member Avatar for kingdeslok

You would first have to encrypt the password, using whatever method your OS uses and then pass the encrypted password (unless it will be encrypted somewhere along the line), as only the very, very foolish store unencrypted passwords. From the rsync man page "Some paths on the remote server may …

Member Avatar for kingdeslok
0
537
Member Avatar for fokys

I would guess that you should comment line #22 as it is a duplicate of line #1, and so tries to open the same connection. For further help, please post the entire error message, as guessing is not a good thing.

Member Avatar for fokys
0
205
Member Avatar for Bosterk

[QUOTE=;][/QUOTE] I would suggest something like the following. I am no SQL expert, but using a dictionary to hold the variables eliminates SQL injection problems, or so we think. [code] cur.execute('SELECT * FROM inventario WHERE codigo==:dic_var', \ {"dic_var":resultado}) recs_list=cur.fetchall() # #-----take a look at the contents of recs_list FYI print …

Member Avatar for Bosterk
0
173
Member Avatar for rhuffman8

[QUOTE=;][/QUOTE] You can multiply the number by 100 and use integers, or truncate to 2 decimal places when printing floats. On most modern computers a float is a binary number as defined by the IEEE Floating Point Arithmetic Standard and represents numbers 1,000,000,000,000 to 0.0000000000000001 (at a minimum). Floats (actually …

Member Avatar for Gribouillis
0
240
Member Avatar for rhuffman8

[QUOTE=;][/QUOTE] You should also be able to use the list as is, something like this: [code]for i, record in enumerate(reader): if (i > 0) and (len(record) > 7): #skip headers & record has all the fields print "date =", record[0] print "hk =", record[1] print "ba =", record[2] ## etc. …

Member Avatar for rhuffman8
0
373
Member Avatar for bmanzana

[QUOTE=;][/QUOTE] Also you should check the value of this statement out = out + key1[key1.index(i)+3] to make sure that key1.index(i)+3 isn't greater than the length of the list, key1.

Member Avatar for bmanzana
0
106
Member Avatar for Bosterk

[QUOTE=;][/QUOTE] SQLite is separate from wxPython, so the two are independent of each other. You can enter a value in wxPython, retrieve the value from the wxPython entry box, and then add it to a SQLite database, or vice-versa. I would suggest starting with a simple program that asks for …

Member Avatar for Gribouillis
0
302
Member Avatar for zentechsupport

[QUOTE=;][/QUOTE] while look () == Void: will loop indefinitely when they are not equal because the contents of the variable Void and the function look() don't change. You might want to send some variable to look() and return something other than the value of the Void when you want to …

Member Avatar for woooee
0
264
Member Avatar for the1last

You can use lists or 2 sets. But you would want both set1.difference(set2) and set2.difference(set1). You can set up a process to read both files like a merge sort would, but the set solution seems more pythonic. Depends on how large the files are though.

Member Avatar for radk
0
16K
Member Avatar for Benderbrau

Is this logic correct? arrive=[0, 3, 6, 7, 7, 10, 15, 16] exe= [12, 3, 11, 1, 4, 5, 20, 7] The first piece arrives at 0 and takes 12 units to complete, so if we add completion time, we have arrive=[0] exe=[12] completion=[12] arrive=[0, 3] exe=[12, 3] completion=[12, 6] …

Member Avatar for majid_shqeer
0
3K
Member Avatar for newtopython1111

[QUOTE=;][/QUOTE] I would suggest printing the first few items in replace. I think you will find that there is more than "tell" in replace, so the line for tell in replace: yields an error. You might try inserting this modification: [code]replace.append(tell) replace.append(line) # # change to replace.append((tell, line)) # # …

Member Avatar for woooee
0
156
Member Avatar for de1337ed

[QUOTE=;][/QUOTE] [url=http://wwwsearch.sourceforge.net/mechanize/]Mechanize[/url] is the standard answer to "how do I fill in a form" type questions. I have not used it so can not say what would be required to use it.

Member Avatar for griswolf
0
3K
Member Avatar for Lolalola

[QUOTE=;][/QUOTE] "Runs too long" usually means an infinite loop in today's fast CPU world, so if the program is interrupted after a certain period of time, the results may not be correct.

Member Avatar for TrustyTony
0
196
Member Avatar for mikedeomon

[QUOTE=;][/QUOTE] This implies [quote]it only returns the details of the last user in the list[/quote]This implies that you only write the last name. You code should be indented as follows, with the write statement under the for() loop. [code]for name in listofnames: account = api.GetUser(name) followers = account.followers_count csvout.writerow([name, followers]) …

Member Avatar for woooee
0
198
Member Avatar for sys73r

[QUOTE=;][/QUOTE] This homework problem comes around every year. [url=http://www.daniweb.com/software-development/python/threads/60188]horizontal and vertical graphs[/url].

Member Avatar for sys73r
0
764
Member Avatar for yuvalm2

[QUOTE=;][/QUOTE] +1 for HTML. People are familiar with web browsers and you can generate the code via Python if you want. [quote]Meaning that if user A asked to perform some task X, which took 10 minutes, user B will not be able to perform a new task Y until X …

Member Avatar for woooee
0
226
Member Avatar for heavy.is.happy

[QUOTE=;][/QUOTE] A button press is associated with a callback, also called signals and slots, which call a function or class to do the actual work. See how the "self.log" button is connected to the "self.log_timestamp" function in Listing3: logger-qt.py [url=http://www.ibm.com/developerworks/linux/library/l-qt/]here[/url] Another PyQt tutorial for [url=http://www.harshj.com/2009/05/14/pyqt-signals-slots-and-layouts-tutorial/]signals and slots[/url].

Member Avatar for heavy.is.happy
0
217
Member Avatar for yuvalm2

[QUOTE=;][/QUOTE] Multiprocessing has a getPid() function, so you can also use the PID.

Member Avatar for woooee
0
70
Member Avatar for codemonster

[QUOTE=;][/QUOTE] First, my personal opinion is that "in" is more straight forward than "-1" [code]#elif self._wordAt[w][-1] != linenum: # occurring on a new line for this word elif linenum not in self._wordAt[w] self._wordAt[w].append(linenum)[/code]To get the number of times it occurs, I would suggest that you print 10 items of the …

Member Avatar for woooee
0
93
Member Avatar for FALL3N

[QUOTE=;][/QUOTE] See "Capturing Output" here [url]http://www.doughellmann.com/PyMOTW/subprocess/index.html#module-subprocess[/url] You can do a lot more with subprocess, so continue reading if you want to know more.

Member Avatar for FALL3N
0
116
Member Avatar for Hawkwing

[QUOTE=;][/QUOTE] You perhaps want something along the lines of: [code]class someclass: def __init__(self): self.somevariable='somevalue' def somefunction(self): print('gotta get here') def someotherfunction(class_instance): print "somevariable -->", class_instance.somevariable print "somefunction -->", class_instance.somefunction() myclass=someclass() someotherfunction(myclass) [/code]

Member Avatar for woooee
0
162
Member Avatar for jmark13

[QUOTE=;][/QUOTE] [quote]and if B[A[100]B0] then B[A[100]B] as the 'A' is considered adjacent to the '0'[/quote]That doesn't make sense to me at least. How is the final "0" adjacent to "A" even when taking the brackets into consideration. [quote]so how can str='A[A[001]BB1A10]11BA10' become str=A[1A[100]BA]BA10[/quote]Where does the first "1" come from in …

Member Avatar for TrustyTony
0
139
Member Avatar for hszforu

I would not be concerned about the differences between 2.6 and 2.7. Using 2.7 is only [URL=http://docs.python.org/dev/whatsnew/2.7.html]slightly different[/URL] than 2.6. There are some third party packages that are not yet available for 2.7 though.

Member Avatar for hszforu
0
194
Member Avatar for andrewtrench

[QUOTE=;][/QUOTE] You open the database for every iteration of the for() loop and while() loop but the close is outside of the for() loop. You should open the SQLite database before the for filename in list_of_files: Then close it at the same indentation level (no indentation) at the end of …

Member Avatar for andrewtrench
0
2K
Member Avatar for rickyfre

I think Python gets the locale from your computer, so perhaps that changed with the installation. You can try locale.setlocale() and see if it helps.

Member Avatar for rickyfre
0
399
Member Avatar for vlady

[QUOTE=;][/QUOTE] Why are you going through the following gyrations instead of using "t". Also, please do not use "i", "l", or "O" as variable names as they can look like letters. [code]t=s.split() delimiter= '' s=delimiter.join(t) l=list(s) [/code]

Member Avatar for vlady
0
1K
Member Avatar for Eswarimallur

[QUOTE=;][/QUOTE] Is "wx" declared somewhere else in the program, so you have one wx over-riding the other?. You will have to post some code for specific suggestions. [quote]Added import wx.lib statement to the script, but still getting the same error[/quote]The same error implies that wx is not installed on that …

Member Avatar for Gribouillis
0
2K
Member Avatar for weezy101

[QUOTE=;][/QUOTE] Dictionary keys are stored in "hash" order, not the order they were entered (a dictionary is an indexed container, not a sequential one). You should either sort the keys, and then use the sorted list to lookup in the dictionary, or use [url=http://www.python.org/dev/peps/pep-0372/]"ordered dictionary"[/url], which usually requires importing "collections" …

Member Avatar for woooee
0
185
Member Avatar for rodm

[QUOTE=;][/QUOTE] The i5 is rated at 2.66GHz (according to HP's website), so a doubling of speed is acceptable compared to a 1.6 GHz machine. The i5 is also a dual processor so you can use [URL=http://www.parallelpython.com/]parallel python[/URL] to speed things up. For a simple function, it would be something along …

Member Avatar for woooee
0
206
Member Avatar for colts18

[QUOTE=;][/QUOTE] pygame has collision detection. Google is your friend. Even it you can't find an answer for your specific object, you can see how it is done with other objects.

Member Avatar for raptr_dflo
-1
473
Member Avatar for jamie-pu

There are a lot of problems with the code you posted: [code]## there is no root window app=RootFinder() app.mainloop() #---------- should be root = Tk() app=RootFinder(root) root.mainloop() # ## self.outputframe is never declared in the code you posted def create_widgets(self): self.root1lbl=Label(self.outputframe, text='') [/code]And that is all that I care to …

Member Avatar for TrustyTony
0
170
Member Avatar for jarograv

Match up the parens on the previous, raw_input, statement. Also, the welcome() function does nothing.

Member Avatar for woooee
0
156
Member Avatar for markfw

I am guessing that the window doesn't contain anything visible, just containers. (This just displays a button.) [code]import sys from PyQt4 import QtCore, QtGui class UI_CMDTester: def __init__(self): self.__app = None self.__win = None def init(self, \ w_title, \ w_width, \ w_height): self.__app = QtGui.QApplication(sys.argv) self.__create_win(w_title, w_width, w_height) sys.exit(self.__app.exec_()) def …

Member Avatar for vegaseat
0
226
Member Avatar for MaYouSHka

[QUOTE=;][/QUOTE] Thanks for stating the obvious. We sometimes get too caught up in problem solving and forget to mention good techniques. Data validation should be the first step.

Member Avatar for TrustyTony
0
339
Member Avatar for HiHe

[QUOTE=;][/QUOTE] The result is correct since you open it for reading before anything is written to it. [code]text = "aim low and reach it" fname = "test7.txt" with open(fname, 'w') as foutp: # write text to file foutp.write(text) # read text from file with open(fname, 'r') as finp: mytext = …

Member Avatar for vegaseat
1
170
Member Avatar for mekhoo

This statement will never be true [code]while decimal == '1' and decimal == '0' : # ---- and this statement is meaningless number=number[/code] And str(decimal) will replace the binaryConvert() function. Also, press the code button to include your code in a readable (properly indented) form.

Member Avatar for vegaseat
0
122
Member Avatar for srw0801

[QUOTE=;][/QUOTE] [quote]]AttributeError: 'NoneType' object has no attribute 'getMouse'[/quote] "win" = constructBoard() = None as constructBoard doesn't return anything. Also, python naming conventions use lower case with underscores for function names, and there it is poor style to construct a separate "main" function, especially since it is never called.

Member Avatar for woooee
0
309
Member Avatar for Behseini

Use [URL=http://effbot.org/tkinterbook/listbox.htm]curselection[/URL] to return the item number selected. Note that the title of this thread indicates that this is a "HowTo", a code snippet on how to do something, and not a question. You will possibly get more views=more responses when it is clear that this is a question.

Member Avatar for Lardmeister
0
9K
Member Avatar for Simplicity.

[QUOTE=;][/QUOTE] It is probably one of these u[0][k+1] but to find it you will have to put everything on separate lines, usually above the error line so it prints before the message, [code]derivative = (u[0][k+1]*u[1][k+1] - u[0][k-1]*u[1][k-1]) # and then break it down further, i.e. the last part of the …

Member Avatar for Simplicity.
0
447
Member Avatar for rssk

If it is easier to understand, reduce the lists first and then create the dictionary. [code]list_1= ['0 ', '512 ', '1 ', '513 ', '2 ', '514 ', '3 ', '515 ', '4 ', '516 ', '5 ', '517 ', '6 ', '518 ', '7 ', '519 ', '8 ', …

Member Avatar for woooee
0
103
Member Avatar for radical43144

[QUOTE=;][/QUOTE] You would use a dictionary of lists, The dictionary key is the person's name or ID, pointing to a list that can contain multiple activities for that person.

Member Avatar for woooee
0
151
Member Avatar for potchi

[QUOTE=;][/QUOTE] We can help you with problems with code that is posted to the forum, but any forum that becomes "FreeProgramming.com" would immediately be buried by the requests for free programming.

Member Avatar for woooee
0
112
Member Avatar for WolfShield

To illustrate that the function is correct: [code]from decimal import Decimal def calculate(num1, num2, oper): if(oper=="+"): answ = Decimal(num1) + Decimal(num2) return answ return 0 ret_ans = 0 for x in range(1, 6): print "%d + %d =" % (ret_ans, x), ret_ans = calculate(ret_ans, x, "+") print ret_ans [/code]

Member Avatar for woooee
0
261
Member Avatar for VulcanDesign
Member Avatar for VulcanDesign
0
542
Member Avatar for imperialguy

[QUOTE=;][/QUOTE] wx has a CallAfter method. It will require some implementation of multiprocessing/threads however you do it since you want to do two things at once: 1) wait for a button press, 2) keep track of the time that has passed. This programs waits for 5 seconds, simulating waiting for …

Member Avatar for vegaseat
0
1K
Member Avatar for Toikkala

[QUOTE=;][/QUOTE] There are several ways to do this. First, you might want to use a menu, with a number input, instead of keying in "aluminium", etc. as they can be spelled differently (aluminum). Then use a [URL=http://www.tutorialspoint.com/python/python_dictionary.htm]dictionary[/url] or list of lists to chain the values to the raw material. [code] …

Member Avatar for woooee
0
255

The End.