2,190 Posted Topics

Member Avatar for Thropian

The short answer is to use [URL=http://effbot.org/tkinterbook/wm.htm#wm.Wm.withdraw-method]withdraw or iconify[/URL] but not all methods are available for all widgets. A simple example that creates a normal Tk window, and a second window with a canvas that is withdrawn when you click the "Continue" button, and is raised with the "deconify" button. …

Member Avatar for Thropian
0
202
Member Avatar for nejger

You would have to test for "(" and then traverse (or split) to the ")". The letters in between would be divided by 1000.

Member Avatar for woooee
0
109
Member Avatar for Hawkeye Python

Adding a print statement should help. If you want to store more than one value, a list is usually the container of choice. [CODE]def gp(a1,r,n): ## can also be done with list comprehension print [ a1 * (r ** x) for x in range(n)] while n > 0: n = …

Member Avatar for Hawkeye Python
0
150
Member Avatar for evertron

You would call it this way (an [URL=http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm]intro to classes):[/URL] [CODE]##Test the Lexicon program print'This is a test program for the Lexicon file' # an instance of the class lex_instance = Lexicon() # the class instance now exists so we can call it's members source = lex_instance.OpenFile('word') [/CODE]

Member Avatar for evertron
0
235
Member Avatar for MaC-CK

Works fine for me. Note that you only have to pass minutes allowed and minutes used to the function. [CODE]def calc_total(minutesAllowed, minutesUsed): extra = 0 if minutesUsed <= minutesAllowed: totalDue =74.99 minutesOver = 0 print "You were not over your minutes for the month." else: minutesOver = minutesUsed - minutesAllowed …

Member Avatar for MaC-CK
0
135
Member Avatar for tk-421

[QUOTE]The Python program I need to write accepts the price of an item, the amount paid for it[/QUOTE]Start by asking and receiving from the keyboard, the price and the amount paid. Yes, we can help you with code you've written, but won't do it for you.

Member Avatar for TrustyTony
0
13K
Member Avatar for Thropian

If I can read the 166 lines of code correctly, what happens when "resting" == 1 [CODE] info_dict["resting"] = info_dict["resting"] - 1 ## it now equals zero, so the following would never execute def slime_move_ready(): ## also add a print statement to see if this is executing print 'info_dict["resting"]', info_dict["resting"] …

Member Avatar for Thropian
0
112
Member Avatar for Favolas

[QUOTE][b,b,a,a,a,a,a,b,b,b,b,a,a,a,a,a,b,b,b,b,a,a,a,a,a,b,b][/QUOTE]You insert 2, then 4, then 4, then 2? Please correct this example or be more specific about what you want. Instead of inserting, it is more efficient to create a new list since every item past the insertion point has to be moved for every insert. You can use …

Member Avatar for woooee
0
115
Member Avatar for sandesh56

Python uses pointers, which means that D=C assigns the memory address of "C" to "D" so they both point to the same block of memory.

Member Avatar for woooee
0
134
Member Avatar for yellowkaiq

[CODE]# the last letter is b,d,g,l,m,n,p,r,s or t if word[wordlength] in ['b','d','g','l','m','n','p','r','s','t']: #and the second to last letter is not the same as the last letter. if word[wordlength] != word[wordlength-1]: # # or (same thing as nested if() statements) if (word[wordlength] in ['b','d','g','l','m','n','p','r','s','t']) and \ (word[wordlength] != word[wordlength-1]): # # …

Member Avatar for yellowkaiq
0
187
Member Avatar for blacknred

I would keep everything between the first ">" and "<" but if all of the records are the same, you could also replace "<TimeStamp>" and "</TimeStamp>" with nothing. Either way will get you to be able to print(datetime.datetime.fromtimestamp(int("1284101485")).strftime('%Y-%m-%d %H:%M:%S'))

Member Avatar for richieking
0
187
Member Avatar for Zealhack

"\n" is the newline character, so you are appending a newline every time you write "answer", so remove it there and add a statement to b.write "\n" every time a comma is found (and it is not apparent from the code posted how you test for a comma). Note that …

Member Avatar for Zealhack
0
183
Member Avatar for M3M69

For the unknowing, this is another example of the "never-ending-questions-with-little-or-no-code" method to get other people to write the code for them. The method is to keep asking questions until someone is worn down enough to write the code for them, while they sit on the veranda in the shade. Let …

Member Avatar for M3M69
0
128
Member Avatar for afireinside

It sounds like you would have to alter the perl script to accept input/inputs from some source other than the command line. You could use multiprocessing to run in parallel, or use one of the parallel python programs, especially if you have multiple cores [url]http://github.com/mattharrison/coreit[/url] [url]http://www.parallelpython.com/content/view/17/31/[/url]

Member Avatar for woooee
0
1K
Member Avatar for Finki

[QUOTE]faces=rect64(acb64583d1eb84cb),2623af3d8cb8e040;rect64(58bf441388df9592),d85d127e5c45cdc2[/QUOTE]It appears that you could split on the comma and then on the semi-colon since you want the last string in the pair. Then flatten the resulting list. Otherwise, parse each line and look for a start and stop copying character (which may be easier to understand and is a …

Member Avatar for woooee
-2
199
Member Avatar for blacknred

It should be easier if you use a dictionary pointing to a list of shares. This code assumes that you do not care about order of execution, otherwise you will have to order the dictionary keys and execute in that order. [CODE]def get_config(): ip_dict = {} done = False deny …

Member Avatar for blacknred
0
90
Member Avatar for yellowkaiq

Print what you have first because it doesn't look like it is doing what you would want if "number_list" is a string and has not been split into words. [CODE]def turn_words_into_numbers(number_list): output = 0 current = 0 for index in range(len(number_list)): current = eval(number_list[index]) print index, number_list[index] [/CODE] Some theory: …

Member Avatar for yellowkaiq
0
207
Member Avatar for Swedenrock

random.sample() returns a list (of cards in your case). [CODE]import random x = ["a", "b", "c", "d", "e"] ret = random.sample(x, 2) print ret, type(ret) [/CODE]

Member Avatar for woooee
0
227
Member Avatar for G-nerd

This line db[j][0]=db[j][1] overlays the English word in the list with the Spanish word. And do not use "sum" as it is already taken by Python for summing numbers, and "i", "l" or "O" are not good choices for single digit variable names as they can look like numbers. [CODE]db …

Member Avatar for Lardmeister
0
234
Member Avatar for haojam

Find where the error is. Print line2[j], j, len(line2) and with a separate print statement a[j], j, len(a). You can then fix the specific problem. Also, include some comments in the code explaining what is happening, so we know what it is supposed to be doing. No one can be …

Member Avatar for haojam
0
690
Member Avatar for z00t

[QUOTE]takes a list of real numbers as input[/QUOTE]And how are the numbers input; from a file, or via the keyboard. Whichever it is, that is where you want to start. Read the input from a file or the keyboard into a list, and post that code for further help.

Member Avatar for richieking
0
120
Member Avatar for Asset

Some modifications to your code 1. Used a list for keywords instead of if() statements 2. Added an indicator that turns on when "description" is found and prints those records. Add whatever to want to process those records instead of the print statement under "if des". [CODE]infile = open("books.txt","r") lines …

Member Avatar for Asset
0
343
Member Avatar for kuchi

It would be something like from cart import items if cart.py is the name of the file. But without knowing what type of object cart and items are, there is no real way to answer the question. Post a simplified example.

Member Avatar for richieking
0
564
Member Avatar for Thropian
Member Avatar for TrustyTony
0
149
Member Avatar for keltik

Since there is no code on how or how many items in self.play_hands were declared, and no error message or what happened versus what was expected to happen, there is no way to comment. Generally, you would use list comprehension. [CODE]self.player_hands=[["Testcard"] for x in range(self.num_of_players)] [/CODE]Also, "i" l" and "O" …

Member Avatar for keltik
0
174
Member Avatar for knan

The limits of floating point numbers [url]http://www.lahey.com/float.htm[/url] [url]http://docs.python.org/tutorial/floatingpoint.html[/url] Use decimal for more precision. [CODE]from decimal import Decimal as dec # 0.1 + 0.1 + 0.1 - 0.3 = 0.0 x = dec("0.1") y = dec("0.3") print x + x + x - y [/CODE]

Member Avatar for knan
0
202
Member Avatar for Sykee

When the if() statement is not executed, there is no "x" to return. Note also that the statement "return y" will never be reached/executed.

Member Avatar for WildBamaBoy
0
249
Member Avatar for n3red

Start with the smallest divisor, 2; see if it is a divisor and increase up to the square root + 1. So in this case 252 / 2 = 126 So 2 is a divisor. Then using 126 (divide by 2 up to square root 126 + 1) 126 / …

Member Avatar for TrustyTony
0
493
Member Avatar for The Dude

Who wants to know this, why do they want to know, and what's their secret motive for collecting all of this information? By definition, no one who takes the test could be a conspiracy theorist.

Member Avatar for The Dude
0
140
Member Avatar for Brickmack

See "Playing & creating sound" [URL=http://wiki.python.org/moin/PythonInMusic]here[/URL]. I have on use Snack so can't really comment on any of them.

Member Avatar for woooee
0
79
Member Avatar for Finki

See [URL=http://www.daniweb.com/forums/thread325522.html]this post[/URL]. If you're not in the same class and have a different problem, post back with the differences.

Member Avatar for Finki
0
207
Member Avatar for flamedragon00

[QUOTE]Use the Date, Volume, and Adj Close fields to calculate the average monthly prices. Here is a formula for the average price for a month, where Vi is the volume and Ci is the day i’s adjusted close price (Adj Close). averagePrice = (V 1 ∗ C 1 + V …

Member Avatar for flamedragon00
0
1K
Member Avatar for Azul-P

Post the code as it is now. Note that you should now be using a tuple, so code has to be changed, like this example: [CODE]# pick one randomly from the sequence word_tuple = random.choice(words_and_hints) # create a variable to use later to see if the guess is correct word …

Member Avatar for TrustyTony
0
2K
Member Avatar for Andrew1988

The brute force way to guess would be to generate a list of 50, or 1000, numbers, and delete the guess from the list. Then use random.choice(numbers_list) to generate the next number. You would also want to slice off part of the list when you change the lower or upper …

Member Avatar for woooee
0
193
Member Avatar for kuchi

Convert to [URL=http://effbot.org/librarybook/datetime.htm]datetime.date[/URL] and you can then compare for greater or lesser than.

Member Avatar for Gribouillis
0
82
Member Avatar for davidgulliaf

Some print statements should help. Note that "word" will only contain the final word in a sentence. Once you can get each word, add a counter to count the letters as they are added to the new "word" field or what ever you wish to use. [CODE]m = input("Enter a …

Member Avatar for woooee
0
122
Member Avatar for fannunziata1

The answer is simple. Put Some Damn Locks On The Lockers! You have to have a way to keep track of the lockers that you understand. It can be as simple as a list of integers that you set to zero/false for closed, and 1/true for open, that is sent …

Member Avatar for TrustyTony
0
157
Member Avatar for victordq

First suggestion is do not post 145 lines of untested code and expect your forum servants to wade through all of it. Second, your if/else indentation is screwy, and there is a while() loop in the middle, which may or may not be at the correct indentation level. Third, you …

Member Avatar for victordq
0
201
Member Avatar for br0wnm4n

Since "lst" is used on 5 lines of the code, there is no way to tell where the error is. General comments would be the list "prime" is an exact copy of "lst" and so you return a copy of the initial "lst" list. Also, print len(lst) before this statement …

Member Avatar for TrustyTony
0
142
Member Avatar for bob24bob

[QUOTE]I want it to simply give me the logged-in users password.[/QUOTE]Generally speaking, programs do not know passwords. A programs takes the password the user entered, converts it using some encryption algorithm, and compares to the stored password (stored in encrypted form only). Otherwise, anyone could steal any password with a …

Member Avatar for crunchie
0
164
Member Avatar for wazaa

[QUOTE]trying to do it with a while loop[/QUOTE]Post your code so we have something to comment on. Also, using a dictionary or list is separate from the for() or while() loop.

Member Avatar for wazaa
0
3K
Member Avatar for c2q

Rolling your own is the best way to go. Alternatively you could replace "?" and "!" with "." and split on the period, but that requires many loops through the file.

Member Avatar for ultimatebuster
0
624
Member Avatar for Smed

What happens if the first "Steve" is 7 instead of 1 -----> ['steve',7, 40], ['steve',3, 20], ['steve',2, 30]], etc. Should it be at the end of the first list or at the end of all of the items? Generally, you would flatten the list and then sort if all items …

Member Avatar for TrustyTony
0
211
Member Avatar for nejger

[QUOTE]I must fix a code so I can write roman letters (bigger than 3999)[/QUOTE]For Arabic, if it is larger than 3999 subtract 1000 and add 1000 to a separate field until it is less than 4000. You would then divide the "thousands" field by 1000, convert and print with parentheses, …

Member Avatar for woooee
0
177
Member Avatar for ds2000

Vegaseat did one a while ago and posted it [URL]http://www.daniweb.com/forums/thread198855.html[/URL] I think most GUI toolkits include methods to do this. [CODE] import Tkinter as tk root = tk.Tk() def show_pw(): pw = pw_entry.get() label2['text'] = pw label1 = tk.Label(root, text="Enter password for user Frank: ") # shows only * when …

Member Avatar for ds2000
0
2K
Member Avatar for ccandillo

You are going to have to store the widgets in a list or dictionary to do that, and tell remove() which one you want to delete. The following is a program that shows how to associate a button to a specific dictionary member by binding a unique instance of the …

Member Avatar for ccandillo
0
288
Member Avatar for pythonlearning

I get an error because .txt was not in quotes. Also note that you will get an aditional error because "options" is declared after the --output parser statement.

Member Avatar for woooee
0
82
Member Avatar for jattvelly035

There is at least one other post on this site that already does this. A search should bring it up.

Member Avatar for woooee
-1
164
Member Avatar for pixelss

[CODE] #repeat print 'Enter type (string)' type = str(raw_input()) [/CODE]"type" is reserved by Python as a function name that returns the type of an object; a string, class, integer, etc. Use "category" or some other name that is less confusing. Also, raw_input returns a string so type casting to string …

Member Avatar for SgtMe
0
906
Member Avatar for Tommymac501

The End.