2,190 Posted Topics

Member Avatar for sandorlev

You use the same StringVar() if I understand what you want to do. Take a look at the following code and note how the StringVar() is declared and then attached to the second Label() and the Entry() box. Note that when the Entry() box changes the second Label() changes because …

Member Avatar for TrustyTony
0
10K
Member Avatar for prashanth s j

A simple test of the following code posted above shows that it will only find 'DTP' if it is at the beginning of the line. It should read as indicated. [CODE]f_in = ["xyz", "abcDTPxyz", "DTPabc"] for line in f_in: ## the if statement should read ## if line.find('DTP') > -1: …

Member Avatar for Beat_Slayer
0
1K
Member Avatar for lrh9

The answer is to develop good habits, one of which is to always use the complete path. It makes everything obvious. This also helps when you come back years later to debug a program because someone has moved something.

Member Avatar for lrh9
0
2K
Member Avatar for ryufire

There are so many examples on the web that I doubt anyone will respond. Try this link [url]http://lmgtfy.org/?q=tkinter+update+time[/url]

Member Avatar for woooee
0
118
Member Avatar for sureronald

A Python list will hold something like 2 trillion items, but is going to be pretty slow with a very large number or records in it. If your list is going to be 100 million records or more, then consider an SQLite database instead. If it's a paltry one million …

Member Avatar for mahesham
0
4K
Member Avatar for G_S

[CODE]def find(): start = 1.0 while 1: find = text_to_be_found.get() [/CODE]It could be that you define "find" as a function and a variable. It could also be that "text_to_be_found" is not within the scope of the function. Print the result of text_to_be_found.get() and see if it is returning anything.

Member Avatar for G_S
0
222
Member Avatar for Priyesh_17

[QUOTE]my code hangs or somehow don't write in the file[/QUOTE] Add some print statements to see where that is. A guess would be that it hangs because it can't find an address or something. There is nothing else to say as we don't even know what you mean by "client" …

Member Avatar for woooee
0
158
Member Avatar for J-M DESMETTRE

Your queries look fine, although I didn't go through all of the code. You may be looking for something that is not in the SQLite file. Design a smaller test program that looks for known items in the file so you can tell if it is the query language or …

Member Avatar for woooee
0
142
Member Avatar for vegaseat

Roman to integer. Note that it will take something like XXIXV and convert it. If someone already has a routine to check for valid input, please post it. And I'm afraid we've just eliminated one standard homework question. Oh well, nothing lasts forever. [CODE]roman_to_decimal = { 'I': 1, 'V': 5, …

Member Avatar for eljakim
0
3K
Member Avatar for MrAlshahawy

The string "127558161.23" would not convert using the time module because it is not a 9 digit integer. Truncating the decimals yields the following result using gmtime() but is not close to the desired date and time. So it appears that the format is not "epoch second" which means a …

Member Avatar for MrAlshahawy
0
206
Member Avatar for lewashby

From the PySQLite docs, a rather dated example; it allows case insensitive column access by name: [QUOTE]Highly optimized row_factory for column access by name ====================================================== A new function has been implemented that allows for case-insensitive column access by name with minimal performance and memory impact, unlike a dictionary or db_row-based …

Member Avatar for lewashby
0
138
Member Avatar for Chupakun

When someone presses the "Run" button, the callback would execute the code from the text-based program, either calling a function or class. You would of course have to import the other program as well. See the button widget here [url]http://effbot.org/tkinterbook/[/url] for info on callbacks. [QUOTE]yet choose the filename and directory …

Member Avatar for Chupakun
0
1K
Member Avatar for hondros

You would use threads, although I use multiprocessing so am not that familiar with threading but here is a link to Doug Hellmann's examples [url]http://www.doughellmann.com/PyMOTW/threading/index.html[/url] The kicker is that the variable used to store the downloaded link must be visible to all threads so the progress bar can calculate the …

Member Avatar for woooee
0
524
Member Avatar for miac09

I would suggest using a dictionary with the individual records in file1 as the key pointing to a list of items found in the other files.

Member Avatar for woooee
0
198
Member Avatar for Tommymac501

It's not that difficult to roll your own. Check each character one at a time in each line and split and append to a list of lists as appropriate. [CODE]for ch in record: if ch.lower() in ["x", "y", "z"]: ## etc [/CODE]

Member Avatar for TrustyTony
0
94
Member Avatar for MoosePaste

Look up the docs for sticky (you have to learn to help yourself). A hint is that there are no variables in your program named E, NE, etc.

Member Avatar for woooee
0
11K
Member Avatar for vlady

Try adding some print statements as below. [CODE]def file1(filename): d1 = dict() fp = open(filename) for line in fp: print "processing file1 line =", line process_line1(line, d1) return d1 def file2(filename): d2 = dict() fp = open(filename) for line in fp: print "processing file2 line =", line process_line(line, d2) return …

Member Avatar for woooee
0
1K
Member Avatar for tzushky

[QUOTE]Problem: I get a double popped up dialog. Why is that? [/QUOTE]You would have to be calling it twice but without any code no one can help. Post a simple example.

Member Avatar for woooee
0
809
Member Avatar for Tech B

There was something similar on planet.python.org recently, and the suggestion was to help upgrade the documentation to get your feet wet and then move on to bug fixes. Contributing to the core of the language always looks good, as opposed to wrapping something that hasn't been done yet, i.e. it …

Member Avatar for woooee
0
130
Member Avatar for SoulMazer

Pass the class instance to the GUI program. An example with all classes in the same program. [CODE]import random class GUIClass: def __init__(self, class_instance): # create a text area named "textArea" # bind the function "OnEnterDown" to the Enter key self.ci = class_instance print self.ci.my_number, self.ci.my_word print "\n calling on_enter_down() …

Member Avatar for SoulMazer
0
125
Member Avatar for helios0684

Try these simple functions, which just contain general SQL statements, and see what you get. This assumes that the table name is "postgres" (from your code") and the user name field is named "username" (again from your code). Since we don't know the table name or layout it is impossible …

Member Avatar for woooee
0
297
Member Avatar for helios0684

Some things that I see in datapull() [CODE]def datapull (username, password): ##-------------------------------------------------------------- ## cursor is never passed to the function ## and there isn't any db table named 'users' cursor.execute('select %s from users') % username ##-------------------------------------------------------------- ## dbcur is never passed to the function # ## and, username and password …

Member Avatar for helios0684
0
485
Member Avatar for ennoil

You can read the entire file into a list, process the list once appending the record number to a dictionary of lists, with the "QA" field as the key. So if record #1 has QA=123 the dictionary would then be index_dict[123] = [1] for record #2 QA = 12 index …

Member Avatar for sergb
0
2K
Member Avatar for vello

I've added a print statement which should clarify what you are actually doing. [CODE]p = [1, 2, 0, -1, 3, 4, 5] smaller = 0 bigger = 0 i = 0 while i < len(p): print "comparing", p[1], p if p[i] >= p: bigger += 1 print bigger i += …

Member Avatar for TrustyTony
-1
161
Member Avatar for atsuko

You could also replace the following: [code]reducedList = [n for n in listParagraph if len(n) == len(word)] ## replace with this reduced_list = [n for n in list_paragraph if word == n.lower()] if len(reduced_list): print "The word", "'" + word + "'", "occurs", len(reduced_list), "times in this section." else: print …

Member Avatar for TrustyTony
0
706
Member Avatar for spikeru

You can use variables for this, if that is what you are after (untested code). [CODE]rotation_in = int(raw_input("Enter rotation ")) for el in rotationarray: if rotation_in == el[3]: print el for x in range(0, el[3]+1, el[4]): ## start, stop, step print x [/CODE]

Member Avatar for TrustyTony
0
503
Member Avatar for ihatehippies

It helps to look at this pictorially. [CODE]0 1 2 3 4 5 6 7 8 9 10 11 <===== number in the list 1* 1 1 2* 2 2 3 4 4* 4 5 5 5 6 6* 6 7* 8 8 8* 9 9* 10 10* 11* [/CODE] …

Member Avatar for TrustyTony
0
167
Member Avatar for DancingDana
Member Avatar for TrustyTony
0
143
Member Avatar for macca21

You would use one separate class as a container for each item, containing the name, id, price, quantity, and any other info for that item. [CODE]class Item: """ contains all information for an item """ def __init__(self, ID, name, price, start_qty): self.ID = ID self.name = name self.price = price …

Member Avatar for macca21
0
97
Member Avatar for prashanth s j

If you are calling the programs from a Python program, you can simply pass the parameter as an arg to the program or to the function being called within the program. Subprocess works fine for this [url]http://www.doughellmann.com/PyMOTW/subprocess/index.html#module-subprocess[/url]

Member Avatar for prashanth s j
0
2K
Member Avatar for macca21

Note that #1 is "Create a new order". Start there. Are you going to use a GUI or the command line to enter the order? Once you have an order, then you have to store it either in memory or on disk, or both. Once you have the orders stored, …

Member Avatar for woooee
0
94
Member Avatar for G-nom

[QUOTE]My second condition is where all the columns have numbers in them.[/QUOTE]This would simply be an extension of your previous code. [CODE]def columns_full(x): """ Returns True if all columns are full Returns False if there are available spaces """ for col in range(5): if x[col][0] == "x": ## Not full …

Member Avatar for woooee
0
114
Member Avatar for mysticstylez

[QUOTE=tonyjv;1223002]Consider which of next words must be replaced if 'of' is in word list: [CODE]'''off shore switch off often "of course" of.'''[/CODE][/QUOTE] The simplest way to handle that is to use a dictionary of lists with the key being the length of the word and the list containing all words …

Member Avatar for griswolf
0
3K
Member Avatar for TrustyTony

You should re-think your logic for the first snippet. And please don't use "i", "l", or "O", especially when you are displaying programing snippets. There are 23 other letters. [CODE]def scanum(x): try: v=float(x) return x except: return False ret_val = scanum(0) if ret_val: print "True" else: print "False" [/CODE]

Member Avatar for TrustyTony
0
1K
Member Avatar for Etinnet

[QUOTE] when moving (or tracing a line) between point A (with coordinates x1,y1) and B (with coordinates x2,y2).[/QUOTE]If you know how to get from A to B, can't you count the number of grids as you go. Assuming that each grid is the same size, you can then multiply, or …

Member Avatar for TrustyTony
0
280
Member Avatar for vlady

[QUOTE]Dictionary doesn't allow to sort the keys or values so in that case I need to transfer it to the list. Is it correct to do it this way?[/QUOTE]That is the way that it is usually done. In fact I can't think of any other way to order keys in …

Member Avatar for woooee
0
143
Member Avatar for netvigator

Try mechanize and see if that is any easier [url]http://wwwsearch.sourceforge.net/mechanize[/url]

Member Avatar for Tech B
0
1K
Member Avatar for TitusPE

You would have to test each record for the specific info you want to keep, "Ship", "start_time", etc., and store it, probably in a dictionary. If the example you posted has not been "improved" for our readability then you can start writing once you hit *END*, headers first and then …

Member Avatar for TrustyTony
0
205
Member Avatar for Mezzck

[QUOTE]I tried to add more entry boxes and make them a difference size then the rest but using the width= under the if ipos: changes them all -__-. [/QUOTE]Just use a separate block of code to add the additional entry boxes that are a different size, or add a width …

Member Avatar for Mezzck
0
440
Member Avatar for chebude

If you want to print one month and not keep the info, then use a list to store all of the values, monthly[0] += rainfall, etc. On the first day of a new month, print the results, zero the list, and start adding again. If you want to retain the …

Member Avatar for woooee
0
148
Member Avatar for Dave Sinkula

[QUOTE]Who would have ever imagined that John McCain will the best choice come this November.[/QUOTE]Whoever raises the most money wins. There are exceptions but very few. It appears that the Democrats are spending their money in the primary. So if McCain comes up with a right-wing vice presidential candidate and …

Member Avatar for jephthah
0
6K
Member Avatar for jpl1993

[CODE]def sort(self, x):[/CODE] It is bad form to re-define reserved words like "sort" so use a more descriptive name (sort what?) and avoid the confusion. Also, you should include one function at a time and test it, then add another, etc. And why are all of the functions staticMethods? Perhaps …

Member Avatar for woooee
0
147
Member Avatar for jib

Sorry, but the question has to be more specific. For one thing, you want to use a loop to deal until the user says stop, so next you want a loop and some sort of input from the user.

Member Avatar for woooee
0
367
Member Avatar for Steven.T

I would suggest that you print Dictionary to make sure that it is in the form you require. You only read the Search file one line at a time: [CODE]Dictionary = set(open("e:/assignment/dictionary.txt")) print Dictionary SearchFile = open(input("Please Enter a File Path: ")) WordList = set() ## WordList is a set …

Member Avatar for TrustyTony
0
185
Member Avatar for jl487

And you have to supply the path unless sample.txt is in your PYTHONPATH. [CODE]os.system("grep %s ./sample.txt" % variable) ## current directory [/CODE]

Member Avatar for TrustyTony
0
11K
Member Avatar for dbphydb

I think you want to join() everything after the first sub-string if destination does indeed contain spaces, or simply split on the colon if you know that there is never more than one in the file. [CODE]for x in ["Branch: ltm_7.4\n", "Destination: Test 5\n"]: x = x.strip() substrs = x.split() …

Member Avatar for dbphydb
0
208
Member Avatar for voolvif

And no one has mentioned an SQLite file on disk because? You could also use dbm or anydbm if you don't want to try SQLite, but speed of these for that many records may or may not be a drawback. Also with these, each key has to be unique, but …

Member Avatar for TrustyTony
0
2K
Member Avatar for ktsangop

As far as I can tell, both of these options work. [CODE]x=16 backslash = chr(92) part1 = '\x03\xa2' part2 = hex(x)[1:] command2 = "%s%s%s" % (part1, backslash, part2) command3 = part1 + backslash + part2 [/CODE]

Member Avatar for ktsangop
0
268
Member Avatar for bbman

For future reference, a Google for "python find from one list in another list" listed this link among others [url]http://www.daniweb.com/code/post968722.html[/url]

Member Avatar for Ene Uran
-1
117
Member Avatar for cchris

No testing is necessary. SQLite has been up and running for years and is fully reliable. Just write your code and go.

Member Avatar for griswolf
0
298

The End.