2,190 Posted Topics

Member Avatar for Kythas

You can read the data into a list. As stated above, the following statement is already a list, so no need for the copy. fdata = open(vhdat).readlines() If there are 544,000 recs and each rec is 100 bytes, that is 54,400,000 bytes (54 megs) of memory. That's very doable in …

Member Avatar for jice
0
134
Member Avatar for kushyer

Install Tile. Google will give a lot of results about Tile improving Tkinter. Also, try other fonts. I like linux-libertine. This will list the fonts that are available. [CODE]from Tkinter import * from tkFont import families import Pmw root = Tk() Pmw.initialise() choice = None comboentries = families(root) ##--- Move …

Member Avatar for kushyer
0
551
Member Avatar for pythonuser

First you have to define "equal". If it means any difference at all then first, see if the two files have the same length. If not, then they are not equal, If they are the same length, open each one in binary mode and read a fixed number of bytes …

Member Avatar for bodhankaryogesh
0
275
Member Avatar for Xlphos

Another threading tutorial [url]http://blog.doughellmann.com/2008/01/pymotw-threading_13.html[/url] but you probably should be using something like pygame.

Member Avatar for woooee
0
142
Member Avatar for drjekil

It's late and I'm tired but this is the general idea if I understand correctly[CODE]data=["1lghB A i 79.8 H H -24.58", "1lghB V i 79.6 H H -22.06", "1lghB H i 71.9 H H -19.94"] for line in data: print "\nlooking at", line substrs=line.strip().split() print "amino acid =", substrs[1], "and …

Member Avatar for drjekil
0
165
Member Avatar for Shakis

I usually use a dictionary or list[CODE]self.input_score_dic={} for m in range(1, 10): self.input_score_dic[m] = Entry(frame,width=6)[/CODE]

Member Avatar for Shakis
0
80
Member Avatar for sicantik03

You are only checking the first record since you only do one readline(). Add some print statements after the while loop so you can see what you are looking through. If you use readlines(), the entire file will be read into a list[CODE]fp = open(modelfilename) data = fp.readlines() fp.close() for …

Member Avatar for woooee
0
141
Member Avatar for valorien

Perhaps you should state why you want to go around pinging sites. os.popen() is probably not the right tool but that depends on what you are trying to do.

Member Avatar for Ene Uran
0
1K
Member Avatar for StudentMark

Look at the info on control variables here. You will probably use .set() to set the contents of the entry widget. If you still can't get it to work, post some specific code. [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/control-variables.html[/url]

Member Avatar for woooee
0
272
Member Avatar for Scala

Add some print statements so you can tell what is going on, such as[CODE] convert_table = {1:{0:0}, 2:{0:1}, 3:{0:2}, 4:{1:0}, 5:{1:1}, 6:{1:2}, 7:{2:0}, 8:{2:1}, 9:{2:2}} yx = convert_table[3] print yx, type(yx)[/CODE]There isn't a y, x in yx (convert_table[choice]). It's a dictionary not a list. You'll have to use something else …

Member Avatar for woooee
0
87
Member Avatar for dabear

Google for "convert 'base 16'" which will hit on general conversions also. The math is straightforward and on a lot of sites, as well as how letters are used.

Member Avatar for ZZucker
-1
78
Member Avatar for Acidburn

Bash will do that for you In Linux. You can also use sys.stdout.write(sys.stdin.read()), although subprocess is now the preferred method. I would guess that on other operating systems it would also be subprocess. This is Doug Hellman's module of the week on subprocess which should get you started [url]http://blog.doughellmann.com/2007/07/pymotw-subprocess.html[/url]

Member Avatar for woooee
0
98
Member Avatar for nish88

Use the show="*" attribute. Also, you are not getting any responses because a Google for "tkinter password" will yield more hits than you can deal with. If this isn't homework, use something found on the web that has already been tested (and is probably written by someone with more Tkinter …

Member Avatar for woooee
0
170
Member Avatar for scru

Don't know if you are aware of Python's webbrowser class. It allows you to display web-based docs, etc. You can choose a particular browser or use the default browser. I don't know if it will tell you what the default browser is though.

Member Avatar for woooee
0
156
Member Avatar for aot

AFAIK you use the Python Imaging Library [url]http://www.pythonware.com/library/index.htm[/url] Perhaps someone else will know more.

Member Avatar for woooee
0
235
Member Avatar for strictlycustom

It's not possible to tell without a line number for the error. I do see that there isn't a comma after overtime in this line print "You earned", pay, "regular pay and", overtime "overtime pay which is a total of", totalpay

Member Avatar for strictlycustom
0
932
Member Avatar for blue_misfit

Use endswith. fnmatch is specific to *nix (I think) and so won't work if you are using MS Windows.[CODE]if os.path.isfile(fullname): # Only work on VOBs and MPGs (for now) if filename.endswith('.vob') or filename.endswith('.mpg'): f.write('dgindex.exe -IF=[%s] -FO=0 -OM=0 -OF=[%s] -MINIMIZE -EXIT \n' % \ (fullname, fullname)) ## ## You could also …

Member Avatar for woooee
0
148
Member Avatar for sam210

For viewing and editing, try passing data to TableListWrapper, [url]http://tkinter.unpythonic.net/wiki/TableListWrapper[/url] The edittest() function is the one to try.

Member Avatar for sam210
0
166
Member Avatar for linkrulesx10

Just to be complete, BLT adds graphing to the TCL/Tk toolkit. Use whichever of the suggestions seems best to you. They will all work. [url]http://incrtcl.sourceforge.net/blt/[/url]

Member Avatar for woooee
0
161
Member Avatar for gwarguy

[QUOTE]Actualy that didnt work. I changed the statements to if sex == "M" or "m":[/QUOTE]An if() statement with an "or" is the same as two if statements (or an elif), so the above equates to if sex == "M": elif "m": I think you want --> if sex=="m" "if m" …

Member Avatar for linux
0
157
Member Avatar for StepIre

Use string.find[CODE]## This code assumes that "blah is always in the string before "notblah" ## and that the sequence is "blah" then "notblah" and not some variation ## of "blah", "blah", "notblah" some_string="ab-blah-cde-notblah-fghij-blah-klm-notblah-no-blah-stu-notblah-xyz" result=0 while result > -1: ## -1 = not found result=some_string.find("blah", result) result2=some_string.find("notblah", result+1) if (result > …

Member Avatar for ZZucker
0
84
Member Avatar for xRuP7uR3x

[CODE]while y < (t - 1): if y == t:[/CODE] Note that (t-1) < t, so y is always less than t and the if() portion will never be executed. You can also use a for loop[CODE]t = len(myint) ##while y < (t - 1): for y in range(0, t): …

Member Avatar for woooee
0
122
Member Avatar for StepIre

Reverse the two for() statements so you only read the file once (and don't use i, l, or o as variable names. They look like numbers).[CODE]for line in f: for j in scorelist if j in line: print j score = score + 1[/CODE]

Member Avatar for woooee
0
91
Member Avatar for huglybits

If the file has Python code, then it should end with a ".py" not ".txt". If it is not a Python file, but a file with text you want to read in the program then you open the file and read it. See #6 here for how to open and …

Member Avatar for 1337455 10534
0
112
Member Avatar for huglybits

[QUOTE]Program should accept a file name as input[/QUOTE]Do you want the program to ask the user to key in a file name, or do you want to provide it as an argument when the program is called, or do you want to use a GUI that allows the user to …

Member Avatar for misty_mirage
0
518
Member Avatar for alivip

You will have to use unicode strings. Here is Guido's tutorial [url]http://docs.python.org/tut/node5.html#SECTION005130000000000000000[/url] From the tutorial, you would use word=u"3ÇáäíÇÈÉ".encode('utf-8') if arabic uses 8 bits per byte.

Member Avatar for woooee
0
153
Member Avatar for okcomputer24

One comment first. You have 2 redundant lines in the original code[CODE]n = int(input("Give me an integer: ")) list1 = [] ##i = 1 ## this line is redundant-the for() loop handles initializing i for i in range(1,n+1): print "i =", i ## this will show what the for() loop …

Member Avatar for woooee
0
76
Member Avatar for linux

You will likely want to use a Tkinter StringVar() with the .get() to get the contents of the entry box. If memory serves - a Google for "Tkinter StringVar Entry" will yield thousands of hits as well var = Tkinter.StringVar() entry_box = Tkinter.Entry(frame_name, width=5, textvariable=var) python_var=var.get() [Under def playCk(self): for …

Member Avatar for linux
0
528
Member Avatar for sigkill9

"return prime" is not indented correctly. For the "print a message if the number isn't even" you already test for even with if n % 2 == 0: ## even . else: ## not even #do what you want here for numbers that aren't even Note that 5 is not …

Member Avatar for sigkill9
0
104
Member Avatar for sigkill9

You can also use a function. Also you calculate math.sqrt(n) on every while loop. Once is enough.[CODE]import math def test_for_prime(n): n = abs(n) j = 2 stop=math.sqrt(n): while j <= stop: if n % j == 0: return False j += 1 return True if __name__ == "__main__": print "This …

Member Avatar for woooee
0
2K
Member Avatar for LanierWexford

Note the number of times you have "ord(letter) + rotate". A little algebra[CODE]## substituting ascii_val for ord(letter) + rotate def rotate_word(s,num): rotate = num % 26 newword = ' ' word=s.upper() for letter in word: if ascii_val > 90: ## ascii_val doesn't exist; this is just for demonstration ascii_val = …

Member Avatar for jrcagle
0
199
Member Avatar for enigmaenigma

if count <= count1: Is count1 delared somewhere? If so, which line is the error referencing. Also, use CODE tags, see this post [url]http://www.daniweb.com/forums/announcement114-3.html[/url]

Member Avatar for enigmaenigma
0
100
Member Avatar for a1eio

Not very elegant, but try to do anything within a try/except?[CODE]try: Tkinter.Label(root).pack() except: print "No window exists" ## Edit: Modifing a well known label example ## Uncomment the root.destroy() line from Tkinter import * root=Tk() def changeLabel(): myString.set("I'm, a-fraid we're fresh out of red Leicester, sir. ") ##root.destroy() try: label2=Label(root).pack() …

Member Avatar for a1eio
0
303
Member Avatar for Zelores

Without the lambda (which you probably haven't covered)[CODE]input_str=raw_input("Enter a string of digits ") ##-------------- Simple way -------------------------------------------------- input_list = [int(x) for x in input_str] print sum(input_list), input_list ##-------------- Check that it is a digit and sum manually ------------------- input_list=[] errors=0 for chr in input_str: if chr.isdigit(): input_list.append(int(chr)) else: print "Only …

Member Avatar for Zelores
0
197
Member Avatar for Leonerd

Take your first post and apply the same logic to both strings, phonebook and inp (for individual character in string). I think you can do the averages, etc.[CODE]inp = (raw_input('Input: ')) phonebook = 'bcdfghjklmnpqrstvwxyz' for ip_char in inp: found = 0 ## reset these variables for each letter in inp …

Member Avatar for woooee
0
205
Member Avatar for linux

I use easyGUI for quick and dirty apps [url]http://www.ferg.org/easygui/[/url]

Member Avatar for linux
0
132
Member Avatar for iamoldest

Not sure what you are asking but try this and see if it helps any. You have to test each individual character and replace the ones that match your criteria. [CODE]for line in self.map: ## one line at a time spaces="" ## move each character over one space for character …

Member Avatar for woooee
0
121
Member Avatar for sigkill9
Member Avatar for LanierWexford

The problem is line 2 fin = open ('E:/words.txt') You open the file as a global and in line 23 process each record in the file via a for() loop, leaving the pointer at the end of the file. So the second time through you read the file starting at …

Member Avatar for katharnakh
0
225
Member Avatar for julichrist

Are you using Samba to connect to MS files? It seems no one here uses unixODBC 2.2.12 or FreeTds 0.64, so you might have more luck asking on the mailing list/forum for those programs, especially since it has to do with ini files and not python.

Member Avatar for julichrist
0
93
Member Avatar for PC_Nerd

To print directly to the printer, you have to access the device driver. I'm on linux so can't help you there. A more common method for simple files that do not have to be formatted is to write the output to a file and use os.system() or subprocess with a …

Member Avatar for PC_Nerd
0
6K
Member Avatar for Raulito

There is a slight flaw in ZZucker's post, but the OP should have reason this out for themselves.

Member Avatar for Ryanvh
0
152
Member Avatar for zclevenger

The assignment says "For a number n, this function determines all factors of n and returns these factors as a list" so I would assume that the number 54 would return (2, 3, 6), and their other half (27, 18, 9) as a list, meaning the program would want to …

Member Avatar for Arob1000
0
344
Member Avatar for abhinemo

Setting a path is OS dependent. In Linux you should be able to use os.system( "export NEWPATH" ) although I haven't tried it. If you want to import a module that is not in your PYTHONPATH then you can use sys.path.append(). Almost every tutorial covers this.

Member Avatar for woooee
0
99
Member Avatar for defience

You can split on the "#" and do a single replace for both characters if that helps That's a single pass through the number string for the split() and a single join to put it back together instead of multiple lookup passes to find and replace each number. Instead of …

Member Avatar for woooee
0
8K
Member Avatar for nure123

Obviously exp() can't use an array as input. This makes sense. I suggest you ask this question on the Numpy board. People there will have more info on how/if you can use an array.

Member Avatar for woooee
0
78
Member Avatar for turnerca902

Do you mean the earliest and latest times for one day in the file. That should be fairly straight forward. min_time=99:99 max_time=00:00 if time < min_time: min_time=time (you will actually have to convert to minutes) elif time > max_time: max_time=time Of course you will have to test for date != …

Member Avatar for turnerca902
0
113
Member Avatar for alexgv14

Print tl, tu, & tm. That should give you some ideas. You might want to use datetime instead or convert everything to seconds.. [code]import datetime today=datetime.datetime.now() midnight = datetime.datetime(2008, 2, 25, 0, 0, 0) if today > midnight: print "today is greater", today, "-->", midnight else: print "midnight is greater" …

Member Avatar for jrcagle
0
119
Member Avatar for Carlo Gambino

Using a for loop might be easier to understand.[CODE]test_list=[1,3,5,7] ctr = 0 stop=len(test_list) for j in range(0, stop): ctr += 1 before_add = test_list[j] test_list[j] += ctr ## ctr = j+1 in this specific case print "element", j, "did =", before_add, "and now =", test_list[j] print "\n", test_list[/CODE]

Member Avatar for jrcagle
0
143
Member Avatar for implor

Try a print str(unicode_string_var) This is assuming that all characters in the variable can be displayed for your locale.

Member Avatar for jrcagle
0
17K

The End.