304 Posted Topics

Member Avatar for Srynx

Nope. Floating point arithmetic error. 0.4 cannot be stored as a finite binary number.

Member Avatar for Srynx
0
144
Member Avatar for HelloPeople1

Instead of: "".join(sPrevHighScore) maybe this: "\n".join(sorted(sPrevHighScore.split("\n"),key=lambda x: int(x.split(",")[1].strip()), reverse=True)) In words: You split sPrevHighScore into lines- You split all lines based on coma. You sort the lines based on the int value of the second tag You sort reversed Tested on: "\n".join(("lorem,20","ipsum,10"))

Member Avatar for slate
0
112
Member Avatar for lamba89

Examine, or post here, the table definition of the table you are inserting. If you have an auto increment field, then you cannot insert values in that. If you are using transactions, you have to commit the transaction.

Member Avatar for slate
0
173
Member Avatar for Python_nooby

You can use os.path.getsize on the file if it is open. But you have to use it on the filename not the file object. [code] f=open("vmi","w") f.write("asdf") import os os.path.getsize("vmi") #0 byte f.close() os.path.getsize("vmi") # 4 bytes [/code]

Member Avatar for slate
0
887
Member Avatar for linuxoidoz

[QUOTE=;][/QUOTE] My tips are: You pass byte string to QLalbel with the wrong implicit encoding. Your font is not able to show the given code point. Can you give use a working piece of code, that producess the error? What is the exception that is showing, if any?

Member Avatar for linuxoidoz
0
2K
Member Avatar for MacUsers
Member Avatar for fugmag

Backslash is an escape character in double qouted strings. You should have "C:\\Bilder" or 'c:\bilder'. Or better use os.path.join. Please read: [url]http://diveintopython.org/file_handling/os_module.html[/url] Parts of: [url]http://docs.python.org/faq/windows.html[/url] And for formal: [url]http://docs.python.org/reference/lexical_analysis.html#string-literals[/url]

Member Avatar for fugmag
0
175
Member Avatar for novice20

You pass the string addr to 2.py. Try printing out the command before you make the call. Correctly: subprocess.call(['python 2.py', addr] ,shell=True)

Member Avatar for slate
0
180
Member Avatar for funfullson

According to [URL="http://portablepython.com/wiki/PortablePython1.1Py2.6.1"]this[/URL], which python module do you use for "project tracing" ?

Member Avatar for funfullson
0
169
Member Avatar for Thisisnotanid

More certain in what sense? You can raise the certainty to a level that is higher than hardware error... If you mean the mean the correctness of the implementation, than you can do testing on prime lists. Or try to proof the code, good luck with that:) If you want …

Member Avatar for Thisisnotanid
0
574
Member Avatar for sanjcee

I could not get the real function of this code, so my post is pure guess.... What does it mean "associate" two lists? If you mean to multiply each element of one list with the other list's respective element and sum them, then (given list1 and list2): sum(a*b for a,b …

Member Avatar for richieking
0
110
Member Avatar for SgtMe

Hello! This is not a python question. It is a windows one. [url]http://support.microsoft.com/kb/307859[/url] [url]http://www.informit.com/articles/article.aspx?p=415193&seqNum=6[/url] If you have found a simple solution, please share it.

Member Avatar for SgtMe
0
235
Member Avatar for hisan
Member Avatar for Archenemie

String.strip removes any combination of the given chars. See python documentation for that. You can use regexp or string.startswith. If the filename starts with the string to be stripped, then change the filename by removing the first charachters that are string to be stripped long.

Member Avatar for Archenemie
0
2K
Member Avatar for fannunziata1

The status of a locker L is calculated by the number of divisors of L. The most naive approach is to count all divisors. The advanced would be prime factorization. If the first locker is indexed by 1 and the last 1000, then [CODE]locker=4 print "open? ",bool(sum(1 for i in …

Member Avatar for TrustyTony
0
158
Member Avatar for evertron

Also in the news [URL="http://tomayko.com/writings/getters-setters-fuxors"]python is not java.[/URL]

Member Avatar for slate
0
137
Member Avatar for sallubhai

[CODE]from __future__ import print_function # labyrinth = \ [[0,0,0,0,0,0,1,0], [0,1,0,1,1,1,1,0], [0,1,1,1,0,1,0,0], [0,1,0,0,0,0,0,0], [0,1,1,0,1,1,1,0], [0,0,1,1,1,0,0,0], [0,1,1,0,1,1,1,0], [0,1,0,0,0,0,0,0]] [[print("##" if char==0 else ".",end="" if i<len(line)-1 else "\n") for i,char in enumerate(line)] for line in labyrinth][/CODE]

Member Avatar for TrustyTony
0
154
Member Avatar for gunbuster363

[QUOTE=gunbuster363;1389332]python.org tell people to forget about python 2 and head into python 3[...][/QUOTE] Where? Who? Let me google that for you: [url]http://tinyurl.com/3xc4tqj[/url]

Member Avatar for richieking
0
223
Member Avatar for amandureja

[QUOTE=amandureja;1387529]Well, after some searching, I have finally got it. So this thread is pretty much pointless now :P But I can post the finished code here if anyone wants it.[/QUOTE] Do it please, and mark the thread as solved.

Member Avatar for richieking
0
2K
Member Avatar for nejger

[QUOTE=nejger;1388319]Hello! (I would like to use tkinter. ) Can someone help me? I don't know how to do it, to put the functions in the buttons etcetc.[/QUOTE] See any tkinter tutorial. For example: [url]http://www.pythonware.com/library/tkinter/introduction/hello-again.htm[/url]

Member Avatar for TrustyTony
0
122
Member Avatar for Friendly Lotus

The label's fg option is not executed when root.update is called. It does not seem logical. You should set the fg option of the label in the command somehow. I am not an expert int tkinter, but recreating it is always a possibility. Textvariable applies only for the text option. …

Member Avatar for TrustyTony
0
15K
Member Avatar for br0wnm4n

A little [URL="http://www.daniweb.com/code/snippet217082.html"]self promotion[/URL] might not be wrong.

Member Avatar for TrustyTony
0
142
Member Avatar for anna514

What operation is d? What do you mean by "maximum value that can be stored in a variable". Is this an arbitrary number? The following "it stays at the maximum" means that no operation is performed afterwards? Is there any unary operator? What is the expected output for that? : …

Member Avatar for slate
0
621
Member Avatar for jice

I think the from line is folded, because it does not contain :. See: [url]http://tools.ietf.org/html/rfc2822.html[/url] If there is a real From line, then the same happens?

Member Avatar for jice
0
185
Member Avatar for nejger

Maybe take a look at [URL="http://diveintopython3.org/regular-expressions.html#romannumerals"]this[/URL]

Member Avatar for woooee
0
177
Member Avatar for king_koder

The possible shots build a directed graph with dead ends, not an undirected one. If you have [URL="http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm"]this[/URL] algo in mind, then it is unsuitable for that without modification... However you can mark dead ends visited, and backtrack. I would maintain a list of current path, and a set of …

Member Avatar for slate
0
508
Member Avatar for prexioso

for n=3: list1=[[member*3+1+i for i in range(3)] for member in range(3)] list2=[[1 if i==member else 0 for i in range(3)] for member in range(3)] Modifying for any n is left to the user....

Member Avatar for prexioso
0
130
Member Avatar for 3FLryan

Hello Ryan! I think the the hardest thing in game development is to have a clear vision and the ability to implement. A vision requires fantasy, the implementation requires discipline. That means the two aspects are mutually exclusive in most people. For python strategy games, I recommend: [url]http://www.emhsoft.com/singularity/[/url] [url]http://www.pyweek.org/e/Tee-py4/[/url] Both …

Member Avatar for 3FLryan
0
190
Member Avatar for longlongsilver

I would gladly help if I would understand what the move method is meant to do. I have read the post 3 times, but I do not get it. Line 13 would raise NameError, if it would be called, because there is no "move" name... Using the class to register …

Member Avatar for TrustyTony
0
158
Member Avatar for noniterum03

I am not sure, I understand correctly. Empirical distribution function is a function with two arguments. The dataset, and a real number. What is your cdf_data is meant to return? BTW you are losing all your data (in self.datalist) by calling cdf_data function. My implementaion would be: [code] def cdf_data(self,t): …

Member Avatar for SgtMe
0
110
Member Avatar for patrickgormally

You have two functions. None of them return anything, so they return None. As you write, your change function is not implemented. Fixed your code: [CODE]COIN_NAMES = ['Dollars', 'Half-dollars', 'Quarters', 'Dimes', 'Nickels', 'Pennies'] COIN_VALUES = [100, 50, 25, 10, 5, 1] NUMBER_OF_DENOMINATIONS = len(COIN_NAMES) def to_cents(amount): ''' Converts the given …

Member Avatar for slate
0
161
Member Avatar for ekkanh

Do you have the filenames in a file? Do you want pipelining, stdout/stdin teeing?

Member Avatar for Gribouillis
0
105
Member Avatar for king_koder

list.index(x) Return the index in the list of the first item whose value is x. It is an error if there is no such item. The expression: data.index(item) does not return always the items index. If you have many equal items, then the first will be returned. I recommend the …

Member Avatar for king_koder
0
406
Member Avatar for Finki

My suggestion is: [CODE] li = raw_input("Type something: ").split() print li [/CODE] Do not use "list" as a variable name. List is a builtin type. The split method of the string does exactly what you except. See documentation for that.

Member Avatar for Finki
0
100
Member Avatar for canadian_girl

Most possibly rounding errors. Suppose your average is for exemple 5, and you want to lower it to 3. Red_ratio will be 0. Set red_ratio to a float and round red*red_ratio instead.

Member Avatar for slate
0
157
Member Avatar for G-nerd

[QUOTE=G-nerd;1377626]thanks so much for your hint. However I still can't get python to print the list without the designated deleted word. When I do run the program it just prints the string inputted into a list. From what I am reading it should delete w because I said for all …

Member Avatar for slate
0
281
Member Avatar for henryford

The 31. line lacks a closing brace ")". The 22. line appends a list to a list. Is this what you want? So 31. line makes an int from a one member list .... 44. There is no quit function You name lstfileNames a list, that contains gross payments. This …

Member Avatar for slate
0
174
Member Avatar for ekkanh

[CODE] class Seats(object): def __init__(self,nr=32): #FIXME arbitrary number of seats self._seats=list(range(1,nr+1)) self._reserved=set() def reserve(self,index): #TODO raise exception when invalid index self._reserved.add(index) def unreserve(self,index): #TODO raise exception when invalid index self._reserved.remove(index) def save(self): #TODO pass def load(self): #TODO pass def __str__(self): out="" for i in self._seats: if i in self._reserved: out+="*"+str(i)+"* …

Member Avatar for slate
0
7K
Member Avatar for king_koder

It works properly, but maybe not as you expect it. It gives back a generator, not a list Try: [code] list(permutations(some sequence)) #or for perm in permutations(some sequence): print perm [/code]

Member Avatar for slate
0
196
Member Avatar for evertron

Consider using python property builtin function. It is built for that. Consider raising exception when the price is invalid. Consider using new style classes if you run python 2.x. If you have questions about that do not hasitate to ask... I do not know what book you have, but it …

Member Avatar for evertron
0
92
Member Avatar for knan

As Shlaa said you have an extra "(" on line 5. The interpreter thinks that the statement continues in the next line, and finds no closing ")" token.

Member Avatar for Gribouillis
0
158
Member Avatar for Teiji

This is not java. You can put any number of classes into one file. You do not have to put any classes into a file, like java does. So the interpreter does not know what class you import by merely importing the module. Assuming you have the two classes in …

Member Avatar for TrustyTony
0
146
Member Avatar for iwanttolearnc

[url]http://effbot.org/zone/pil-changes-116.htm[/url] [CODE] import numpy, Image i = Image.open('lena.jpg') a = numpy.asarray(i) # a is readonly i = Image.fromarray(a) [/CODE]

Member Avatar for iwanttolearnc
0
210
Member Avatar for nor_fairuz
Member Avatar for tpkemme

[CODE] while not is_indented(text): print("Please apply code tag to your code!") [/CODE]

Member Avatar for TrustyTony
0
152
Member Avatar for ddalgibbang

You enter the function that is one. Then you make n times, the followings: 1. You check if n>0 2. You print n 3. You divide n by 2 and store it in n Practically the first line is executed once, the other three executed n times.

Member Avatar for Gribouillis
0
115
Member Avatar for dustbunny000

Suppose you have a score function that gives score to each letter. So the score of all the windows is: sum(sum(score(c) for c in w) for w in window)

Member Avatar for slate
0
183
Member Avatar for Overachievious

You do not have a return statement in your lettercount function, so it returns None. Otherwise: result="".join(i[1] for i in sorted(lettercount(String2)))

Member Avatar for TrustyTony
0
226
Member Avatar for JJBallanger

[QUOTE]I have recently been given quite a complex piece of work to do by my computer science supervisor. The idea is that the function:- [def shape_resistivity(shape,R):] allows the user to input a shape and resistance value like so: [/QUOTE] And what is the expected output?

Member Avatar for JJBallanger
0
630
Member Avatar for revellution

I see no big problem with the script. Most of my feedback is coming from the assumption, that the program gets bigger, and must be maintained in the future. [LIST=1] [*] I recommend using python 2.x. Most libraries and people use this, and there are big differences on the beginner …

Member Avatar for revellution
0
125

The End.