2,190 Posted Topics

Member Avatar for varuab

[QUOTE]i want to get this:['10','00','011','10','00','011','10','00','1101','010','1111','1100',1110'] using : word = '1000011100001110001101010111111001110000' [/QUOTE]But you could also get '10' & '000' for the first two, as '000' is also one of the dictionary values. You will have to weight the values and check in that order. So, to check with the length of …

Member Avatar for woooee
0
155
Member Avatar for aot

You maybe want "focus" or "geometry" depending on what you mean by "mouse position". You can find examples for both of them here [url]http://infohost.nmt.edu/tcc/help/pubs/tkinter/[/url]

Member Avatar for Gribouillis
0
4K
Member Avatar for Simes

The second while/break statements in displayMenu() does nothing. You can delete them. And just use another function to write to the file. [CODE] def displayMenu(self): while True: print self.menu input = raw_input(""); if input.upper() == "V": ## while input.upper() == "V": fileHandle = open ( 'scores.txt', 'r' ) str1 = …

Member Avatar for Simes
0
410
Member Avatar for swish123

Generally, you use an increasing counter, increasing every time a prime number is found, until it reaches n. For how to find primes, there are literally thousands of posts on the web. [url]http://www.daniweb.com/code/snippet216880.html[/url]

Member Avatar for woooee
0
150
Member Avatar for qwertyui

[QUOTE]i have 2 list contaning 4 element [/QUOTE]= 8 elements total [QUOTE]I must create 2 new list which contain 2 element[/QUOTE]= 4 elements total. What happens to the other 4 elements?

Member Avatar for woooee
0
175
Member Avatar for davethebear10

You want to return the string found from each of the functions, instead of writing it to a file. Then, if conditions are met, write them all to the file. So readfiles() would be similar to the following using your existing structure. [CODE]def readfiles(filename): filelist = open(filename) write_owner = "" …

Member Avatar for woooee
0
252
Member Avatar for axa121

This will yield the correct results using your test data, but you will have to figure out how to get it to work with your input file. [CODE]country = ["Germany","France","Italy"] medals = ["Gold","Silver","Bronze"] event = ["Luge men's single"] data = {} for this_country in country: data[this_country] = {} for this_event …

Member Avatar for axa121
0
92
Member Avatar for Mensa180

He possibly means subtracting Jan 1st from today. [CODE]import datetime today = datetime.datetime.now() date_diff = today - datetime.datetime(today.year, 1, 1) days_of_year = date_diff.days + 1 print days_of_year [/CODE]

Member Avatar for Mensa180
0
169
Member Avatar for a.w.howell

Two possibles would be to change %.2f to %3.2f which can mean a total of 3 bytes, one before and two after the decimal. If your OS interprets this way, then you originally have zero bytes allocated to the float. Second, omit the epsilon an see if the numbers print …

Member Avatar for woooee
0
144
Member Avatar for txwooley

Try "import Tkinter", note the capital "T". You have to have a match between the tkinter version and the TCL/Tk version. TCL & Tk should be subdirectories in /usr/lib and would be version 8.5 to go with Python 2.6x. Tkinter will be in /usr/lib/python/lib-tk. Also, python has to be compiled …

Member Avatar for woooee
0
162
Member Avatar for emma.parsons

You can sort a list of lists on any element using the operator itemgetter [CODE]import operator test_list = [ ["a", "b", "c", "d", "e"], ["e", "d", "c", "b", "a"], ["c", "d", "e", "a", "b"] ] for j in range(0, 5): print j s_list = sorted(test_list, key=operator.itemgetter(j)) print s_list [/CODE]

Member Avatar for woooee
0
157
Member Avatar for jgehlot09

You might want to re-think/modify the following. [CODE]if match: assign(filename, counter, path, extension) counter += 1 [/CODE]

Member Avatar for woooee
0
158
Member Avatar for meisterluv

Do not use things you do not understand. You may fix this error, or you may just make the error more subtle. You have no way of knowing since you don't understand it. This code has everything that you shouldn't do. And is probably done by a lazy coder. Pass …

Member Avatar for slate
0
213
Member Avatar for soUPERMan

Convert the integer to a list or string and iterate over each element/character. You can use a while loop or a for loop.

Member Avatar for willygstyle
0
1K
Member Avatar for JaxConer

That's in every tutorial so you're not going to get many responses. Take a look at "Variables" here [url]http://www.greenteapress.com/thinkpython/thinkCSpy/html/chap02.html[/url] And learn to print things. [CODE]print range(1, 6) for x in range(1, 6): print x [/CODE]

Member Avatar for vegaseat
0
132
Member Avatar for idreu2go4it

myList is always empty. And what happens when someone chooses '5'? [CODE] ## ************************************* myList = [] ## ************************************* option = displayMenu() while option != '4': # Set up menu choices. if option == '1': getLastName(myList) elif option == '2': getFirstName(myList) elif option == '3': getPhoneNumber(myList) option = displayMenu() print …

Member Avatar for snippsat
0
280
Member Avatar for pythonNerd159

No one is going to help you without knowing which f---- GUI toolkit you are using, and code posted between code tags --> click on the [ code ] icon at the top of the box, and post your code between the two code tags.

Member Avatar for bvdet
0
121
Member Avatar for ChargrO

"This code is too confusing" is too vague to really respond to, but here is effbot's tutorial. Effbot is a good source for examples. [url]http://effbot.org/tkinterbook/menu.htm[/url]

Member Avatar for woooee
-1
138
Member Avatar for smithy40000

You can not mix canvas and grid. To use a label, button, etc. you must add a frame to the canvas. The following example will get you started on this, as well as using a for loop to create the square. [CODE]##------- Do not import Tkinter twice; use one or …

Member Avatar for jimothy
-1
229
Member Avatar for hsyuen

That's because the directory was changed in the bash shell (os.system) and not in the python shell. Why not just use os.system("ls /opt/WindRiver") or, since we now use subprocess subprocess.call("ls /opt/WindRiver", shell=True) You can use python's os.chdir("/opt/WindRiver") but it is better to always use absolute path names to avoid the …

Member Avatar for hsyuen
0
109
Member Avatar for Compy

[QUOTE] File "C:\Python26\getcard.py", line 22, in giveCard [/QUOTE] It appears the error is in getcard.py, which you did not post, and not in testmod.py which you did post. The code you posted worked fine for me. BTW the following will only work for self.Tcard == 11, not if it equals …

Member Avatar for Compy
0
147
Member Avatar for Whoever90

How do you get from here Input String : XYZZXXYYXYZZXYZ to here (and what happened to the final "Z") Unique Prefixes : ['', 'X', 'Y', 'Z', 'ZX', 'XY', 'YX', 'YZ', 'ZXY'] to here [and is (3,'') the final Z] Encode List : [(0, 'X'), (0, 'Y'), (0, 'Z'), (3, 'X'), …

Member Avatar for Whoever90
0
188
Member Avatar for __qwerty__

[QUOTE]I need to check if a float number has decimals or not.[/QUOTE]Convert to a string, split on the ".", and see if the number after the decimal is greater than zero. You can also use divmod which returns the whole and decimal parts of a number x = 2.5 print …

Member Avatar for __qwerty__
0
150
Member Avatar for cerralife

You can use the step function of a for loop to reverse every pair of two letters. The logic for removing a double letter would be similar. [CODE]def switch_letters(word): word_list = list(word) for j in range(1, len(word), 2): word_list[j-1], word_list[j] = word_list[j], word_list[j-1] return "".join(word_list) print switch_letters("cat") print switch_letters("antidisestablishmentarianism") [/CODE]

Member Avatar for Gribouillis
0
182
Member Avatar for Begjinner

You don't have a newline on the last line of the test data so "\n" is never found". You can add a newline to the data or test for EOF and if -1 is not a newline, then add one. [CODE]def test_func(thetext): for i in range(1,26): t = 0 for …

Member Avatar for Tech B
0
121
Member Avatar for mattj63

Do it in one pass by converting to a dictionary of lists which can then be copied to the file. [CODE]test_list = [ {'item1':3, 'item2':3, 'item3':5}, {'item1':2, 'item2':6, 'item3':3}, {'item1':18, 'item2':12, 'item3':1} ] redone_dict = {} for dic in test_list: for key in dic: if key not in redone_dict: redone_dict[key] …

Member Avatar for mattj63
0
1K
Member Avatar for Fridericus

On my machine, Slackware Linux, the message box returns' True' not 1, which may be causing part of the problem. Try the code below and see what it is on your OS. Also, you can just use if tkMessageBox.askyesno(title='Invitation', message =text): which would take care of both situations. [CODE]import tkMessageBox …

Member Avatar for Fridericus
0
388
Member Avatar for polopaul

if (seq_record.seq[count] == "A") : There is apparently a 32K limit on the number of records (short integer, signed). You will have to come up with a way to split the data up or use another method to read.

Member Avatar for woooee
0
98
Member Avatar for peppermints

Your indentations are not correct, and you want to do something else if no files are found. And this is the most that I am willing to do to clean up the screwy tabs and spaces in the code so I hope it is legible. [CODE]def open_file(): if '.trv' in …

Member Avatar for woooee
0
197
Member Avatar for Purnima12

There any many ways to go about it. This uses a list of tuples. [CODE]""" Thanksgiving: 11/ 26 - 11/28 Winter Recess: 12/24 - 01/16 Martin Luther King's Birthday: 01/18 Presidents' Day: 02/15 Spring Recess: 03/15 - 03/20 Memorial Day: 05/31 Independence Day: 07/05/08 Summer Recess: 08/7 - 9/6 """ …

Member Avatar for vegaseat
0
1K
Member Avatar for XD3ADX

The only 'problem' that I see is that you are using the reserved words, 'list' and 'sorted', as variable names, and that you are sorting 'list' and not 'unordered'. Otherwise it looks fine so you will have to be more specific about the problems.

Member Avatar for woooee
0
77
Member Avatar for doctorjo5

This line does nothing [CODE] if len(modified) == 0 : continue [/CODE] [QUOTE]Look at the second word of the *new* list. If it does not contain "trunk" or "branches", skip the line. (stuck on this) [/QUOTE]Use the "in" keyword. [code]**--- will return a positive for words like "strunk" found = …

Member Avatar for woooee
0
184
Member Avatar for Lolalola

[CODE]test_list = \ ['<div tal:define="number python: 1">', '<tal:block repeat="item s_items">', ' <div tal:define="number python: number + 1">', ' <div tal:content="python: number">none</div>', ' </div>', '</tal:block>', '</div>' ] found = False for rec in test_list: if rec.strip().startswith("<tal"): found = True elif rec.strip().startswith("</tal"): found = False if found: print rec [/CODE]

Member Avatar for Lolalola
0
140
Member Avatar for herrschteiner

If you want to be sure that you only sample the same three values once, then you will have to keep track of the threesome somewhere, as each individual value could be used in another threesome. I don't know how many possible 4 digit permutations, randomly associated in triples there …

Member Avatar for herrschteiner
0
222
Member Avatar for MichelleCrews

[QUOTE]im jus learning how to use the accumulator but i still need sum work lol ...can sum one help me?[/QUOTE] First, not too many people are going to take the trouble to translate kiddie-speak into English. Second, the customary way is to send one number to magic() and have it …

Member Avatar for MichelleCrews
-1
505
Member Avatar for edy_sze

And you should perhaps leave it as a list to avoid any string slicing later. You can also use list comprehension to prepend the zeros which will be faster. This is only an example, since I'm not sure what is going on. [CODE]def IntToNBytes(integer, n): tmphex = hex(integer)[2:] tmphex_list = …

Member Avatar for edy_sze
0
137
Member Avatar for Purnima12

What about floating holidays like Easter, (Easter falls on the first Sunday after the first full moon after the spring equinox unless the full moon is on the equinox in which case it is after the following full moon), and Thanksgiving, which is easier but still not a specific date. …

Member Avatar for woooee
0
162
Member Avatar for gloris

Just call 'ps aux' and pipe the output to a file. You can then read the text file and find whatever you want.

Member Avatar for woooee
0
63
Member Avatar for jjrrmm

[QUOTE]phi = f1 (f1 - 1) + f2 (f2 - 1) + ... + fn (fn - 1)[/QUOTE]Someone is going to have to explain where f1, f2,... come from or what they mean.

Member Avatar for woooee
-1
243
Member Avatar for Andy_Ballard

Python uses references to point to a list, so you can use lists to do what you want. A linked list is one method used to do this depending on the specifics. [CODE]AllAtoms = {} AllAtoms[0] = [0,[]] AllAtoms[1] = [0,[AllAtoms[0]]] AllAtoms[2] = [0,[AllAtoms[0]]] print "Original" for item in AllAtoms: …

Member Avatar for Andy_Ballard
0
233
Member Avatar for Lolalola

I found no Image module in Tkinter, WxPython, or Qt, so just a wild guess would be that you are not allowing for the thickness of outside lines. If you are drawing a right angle, the insides would touch but there would be a gap from outside to outside.

Member Avatar for woooee
-1
72
Member Avatar for conord

I have always found it necessary to use shell=True, on Linux machines anyway. p = call('DAZZLE tmp\163282.xml', shell=True)

Member Avatar for woooee
0
143
Member Avatar for doctorjo5

The only things you can search for that I can see would be two colons in the line, str.count(), and if found, "Jan" through "Dec" (or "Mon" through "Sun" but they don't all contain the day). If they are both found, you can split and search for the string that …

Member Avatar for doctorjo5
0
208
Member Avatar for james0192

The "Usage" example on the home page explains it. You call the class for the particular type of barcode you want with the bar code number as a parameter.

Member Avatar for woooee
0
60
Member Avatar for james0192

You don't return anything from the function datetimedtoday() so calling it doesn't return any date. [CODE]import datetime from Tkinter import * class Class1: def __init__(self): obj1= Class2() self.root = Tk() self.root.title("test window") self.can1=Canvas(self.root, width=500, height=510, bg="black") self.can1.pack(expand=False, fill=X) self.label1 = Label(self.can1, text =obj1.datetimetodayday() , bg = 'black', fg= 'red',font=('Arial Black', …

Member Avatar for woooee
0
2K
Member Avatar for kfancy

For starters, you can use a dictionary and a list in the Card class. Test each class and function individually, whether it is in a class or not, before you include it your main program so you know that it works properly and returns the correct value. You obviously have …

Member Avatar for woooee
0
170
Member Avatar for Kruptein

Once you read a file, that is it, unless you go back to the beginning and start over again, so after the first pass, g.readlines() does nothing. Instead, I think it is save to store the whopping 15 lines in memory as a list and iterate over the list. In …

Member Avatar for Kruptein
0
175
Member Avatar for Hawkeye Python

A string is always larger than a number (any number). Better re-read your other thread and if you are not sure, print type() for both variables.

Member Avatar for snippsat
0
120
Member Avatar for donnyv

Python's xls reader and writer are here [url]http://pypi.python.org/pypi/xlrd[/url] [url]http://pypi.python.org/pypi/xlwt[/url]

Member Avatar for J-M DESMETTRE
0
237
Member Avatar for axa121

Try line = line.strip() ## instead of line = line[:-1] or make sure there is a return/newline in the last line of the file.

Member Avatar for axa121
0
146

The End.