3,386 Posted Topics
![]() | Re: > people complained that the "favorite" forums it showed weren't where they wanted to go usually. How about putting selection boxes beside the forums member contribute in user page or similar thing in **EDIT PROFILE** and show only those? ![]() |
Re: Still better, you can do that yourself, just read http://docs.python.org/tutorial/ first. | |
![]() | |
Re: Hint, this guesses the spelling from sentence from keyboard: # replace the raw_input with your file read function s = ' '.join(correct(word) for word in words(raw_input('Give sentence: '))).capitalize()+'.' print s The function overfavors shorter words quite much so it suggests *day* for correcting *tday*, even *today* is more likely to … | |
Re: Something along the lines of http://code.google.com/p/perfmetrics/ for Windows or [iotop](http://www.serverwatch.com/tutorials/article.php/3859271/Monitoring-Disk-Usage-With-Iotop.htm) for Linux? | |
Re: def print_reverse(s) for x in reversed(s): print(x, end = " ") | |
Re: lines 8-12 are misindented, quotes are not allowed in IP addresses (FtpIP is also against the Python naming convention suggesting it is class, not variable): import ftplib import re with open("params.txt", "r") as param: for line in param: if re.match("(.*)IP(.*)", line): print ("" + re.sub('IP = ','',line)) FtpIP = re.sub('IP … | |
Re: Yes you are, you import idlelib.PyShell. | |
Re: Take out .Keys()(it is .keys() but it is default for iteration) Variable name number is not logical for string. | |
Re: .... You notice that your mobile has 1000 times the storage of your first computer... And 10 times your university mainframes! | |
Re: You can put everything inside while True: loop, you may use break instead of exit then. Or you may move opposite of your exit condition as while condition. | |
Re: You searched Daniweb, didn't you? http://www.daniweb.com/software-development/python/code/216863/zip-and-unzip-an-archieve-of-files-python ,for example, did not help? | |
Re: Also you can not use integer valued variable length as function like you are doing at line 12. | |
Re: Need information of the context of your question. | |
Re: I do not have android myself, but why not just use Android Scripting Environment and Python? | |
Re: Post your code to understand your request better. | |
Re: This much I got running, the gifs were missing so I had to replace them with something from myself. [CODE]import pygame, sys, os #Player Class, moves according to keyboard input class Player: #Player Constructor, takes arguments image and position def __init__(self, image, x, y): self.image= image self.xPos=x self.yPos=y self.dir=1 #Updates … | |
Here are instructions for voting for winner of the code snippet competition! http://www.daniweb.com/community-center/threads/429756/code-snippet-contest-...-cast-your-vote | |
Re: From widget method of the event parameter. | |
Re: new.write('\n'.join(keep)).rstrip('\n') (or .lstrip if in beginning) instead of lines 18-23 ? | |
Re: Usually you would have more that one piece in list. Also you do not recreate object when you change it's position. Position would be more natural to be a (named)tuple or list also. For movement you usually need to check if Board position is unoccupied, so normally you should have … | |
Re: You do not need to store the years, just do for loop after determining the last year you need to test and do function for [testing for leap year](http://en.wikipedia.org/wiki/Leap_year#Algorithm) you call inside the loop. | |
Re: I do not want go give direct solutions, but here could be usefull one from my [100+ code snipets](http://www.daniweb.com/members/734700/pyTony/code/) : http://www.daniweb.com/software-development/python/code/321725/lowercase-word-generator That could give some ideas including the discussion of various methods. | |
Re: Take care with test cases 24:00 -> error 00:00 -> OK | |
Re: If you thinki it is fully working, why not post it as **Code Snippet**? | |
Re: Surely it is possible, but why would you not use a normal dict or object? | |
Re: In Python strings are Unicode, and what you are talking about is encodings of bytes. Use bytes type and it is just bytes. If you want to encode them in utf8, do so explicitely. But for me that does not make sense as it is variable length encoding of all … | |
![]() | Re: You just need to put next element in order to sorted data structure and drop biggest (k+1st) if size exceeds k. The answer is kth element if length is k, error otherwise (less than k values read) |
Re: Python.org website is a great place for all kind of help, learn to use it: http://pypi.python.org/pypi/setuptools/ | |
Re: What part of **Computer Science** your question is, looks like you posted C code here? I transfer your post to correct forum. | |
Re: Even more difficult for us when we do not even know what those error messages are. | |
Re: You have your values and keys reversed, looks like. It is simple to reverse a dict however if the values are unique: data_reversed = dict((b,a) for a,b in dataDict.items()) | |
Re: > 'd\xc3\xb3\xc3\xb1ez What kind of encoding you are using, utf8, it would seem: >>> print 'd\xc3\xb3\xc3\xb1ez'.decode('utf8') dóñez >>> | |
Re: words global variable has no value, main is never called (and name is misleading as it does nothing but sets local variables and exits.) | |
Re: Why should you want to print binary data as string, it is list of bytes, not characters > print ("received message:- ", data,addr) print("""received message:- %s from %s""" % (data,addr)) # produce same output in Python 2 as in Python 3 | |
Re: Most used term is maybe multi-precission numbers. Be sure not to forget first to test candidates with pseudoprime test like http://mathworld.wolfram.com/Rabin-MillerStrongPseudoprimeTest.html | |
Re: Use dictionary of strengths. Your functions player and rat do nothing. import random player= dict( hp = 100, att = random.randint(10, 30)) enemy = dict( hp = 20, att = random.randint(5, 25) ) attack = player['att'] - enemy['hp'] print(enemy['hp']) | |
![]() | Re: It makes no sense to optimize fibonacci when using only standard precicions, as you can precompute the lookup table and do lookup in O(1) from the table. 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 … ![]() |
Re: I think in GUIs generally you just set user timer event after 6 hours for update event and do nothing. No threads are needed. | |
Re: Second one is easier, the form without True is definately better in my opinion. The first condition with only returns I would actually use ternary condition: def test(val): return a if val > 10 else b else-less if I would usually use with condition that have not much connection to … | |
Re: All code must be inside functions, except any code you want only run when running directly, which you can put inside if __name__ == '__main__': | |
Re: See the http://www.genetic-programming.org/ Examples http://www.genetic-programming.org/combined.html | |
Re: try except statement is usually considered most Pythonic , "ask for forgiveness, not permission" You could consider however using least efficient common way as default, which works both for mutable and immutable object. Then you could offer optimised version mutating the parameter. This could be good as natural way to … | |
There was discussion thread http://www.daniweb.com/software-development/python/threads/424953/polynomial-division for class based implementation for polynomials, and I developed a version utilizing the magic methods to enable operation with normal arithmetic operation. I only inherited sequence structure from list type. Interoperability with scalar types is not implemented to avoid too complicated type checks of the … | |
Re: As the rule was missing from the rules, I of course had to **check if it is possible** to vote yourself by trying it out, and it was. Even in my mobile I only saw the first two columns and did not vote for all categories due to that. I … | |
Re: You would save movement status of each ball in Ball object itself, list or dictionary. Then you would have after event which you would set up to call the updating function for movement, say after 0.05 seconds. | |
Re: >>> class NewClass(object): def __init__(self, **kwargs): self.__dict__.update(kwargs) def __repr__(self): return self.__class__.__name__ + ': '+ ', '.join('%s=%s'%(k, v) for (k,v) in self.__dict__.items()) >>> test=NewClass(a=1,b=2) >>> test NewClass: a=1, b=2 |
The End.