3,386 Posted Topics
Re: you are probably not stripping punctuaztion from words. | |
Re: Latter causes uninitialized variable error if true variable is not defined. Python is case sensitive. | |
Re: Usually in object oriented design you would do for example class Ship(object): def __init__(self, name): self.name = name def __str__(self): return 'Ship(%s)' % self.name __repr__ = __str__ class Game(object): def __init__(self, ship_count = 3): self.ships = [Ship(str(n)) for n in range(ship_count)] self.score = 0 def __str__(self): return 'Score: %i Ships: … | |
Re: # Speed/Time/Distance # Velocity/Lambda/Frequency # d = speed*time # v = frequency*wavelength try: input = raw_input except: pass class Formulator(object): def __init__(self): speed = 0 time = 0 distance = 0 velocity = 0 wavelength = 0 frequency = 0 unit = "undefined" def speeddistancetime(self): pass def speedlambdafrequency(self): pass def … | |
Re: dictionary exists just for that purpose. | |
Re: Use [after timer](http://www.daniweb.com/software-development/python/code/384025/color-changing-window-demo-of-tkinter-after-timer-events) style of event. I do not know exactly how you do that in gtk. | |
Re: 72 to 75 indention at least is messed up. | |
Re: All of us have been new once, it is not sin. Just take one step at time and test your code. | |
Re: what is this supposed to mean, n is not <= 0? range(n-1,0) If I assume you mean range(n-1) (loop 0, 1, 2, 3) then the same result I would make with this with list comprehension n = 5 print [2**i * 3**j for j in range(n-1) for i in range(j)] | |
Re: import itertools def cleanup(lst): def drop(x): return lst[x] == 0xFFFF return lst[:next(itertools.dropwhile(drop, reversed(range(len(lst)))))+1] print cleanup([0x123D, 0x844F, 0x33E9, 0x1234, 0xFFFF, 0x2342, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF]) | |
Re: Only do not use o or l as variable names, they are too easy to mix with 0 and1 | |
Re: mark_sentance is undefined, alter_list is never called. Why only slice of 5 news, how long they are? You call them row. | |
Re: Still it is nice to have those suggestions on earlier threads jump to suprise you ;) Only I hope newbies do not become afraid to post new thread and jump to those and resurrect them from dead. Here one example case very dear to all moderators, I am sure. (no … | |
Re: Could be usefull also, if you do not mind switching to QT: http://sourceforge.net/projects/pythoncad/ | |
Re: Did you try the web server script from http://twistedmatrix.com/trac/ . ![]() | |
Re: Do dictionary mapping the denominations to their numeric value. | |
Re: You set m as integer at line 15. Do you mean `m*v`? But that is just same as v as m is allways 1. Same way line 37 means only that v = p. Also you never exit the while loop. | |
Re: ... and if it is really main function you should call it only once from end of the module. | |
Re: Give error message and relevant inputs with problematic code and explain how the output/result differ from your expectations. ![]() | |
Re: Work with coumts of unique dice values not individual dice. | |
I have a friend laptop, which shortly recovered running without battery by cold treatment in freezer for two hours, but got symptoms back after trying to charge the battery overnight. Now it again tries to start, accesses the DVD drive and lights up some leads, but not by Power switch … | |
Re: You are calling the function instead of passing as command parameter. | |
Re: Hmmm... regression for version 3.3.0, except numpy and Python2 edge does not seem to go away. Lets try shedskin also, it has not multiprecission though. Actually maybe the reason for disadvantage of Python3 is because there is not short integer type? | |
Re: That command is for shell/cmd.exe (WindowKey-R cmd <enter key>) not to python read-eval-print loop of interaction aka Python prompt (>>>) | |
Re: >How about a link back to this thread, as to avoid having to keep up with multiple threads about the same thing? Done: http://www.daniweb.com/software-development/python/threads/424765/code-snippet-contest | |
Re: Write down how you do it yourself step by step, then write program for computer to do same. | |
| |
![]() | |
Re: Use new or old C style formatting: https://pythonadventures.wordpress.com/2011/04/04/new-string-formatting-syntax/ | |
Re: http://www.daniweb.com/community-center/daniweb-community-feedback/threads/436270/daniweb-1000000-members | |
Re: Think what would be the exit condition of the loop according to task. How could you express it as **continueing** condition of while? | |
Now finally you warn discarding the post in the middle by leaving to other Internet page, thank you! | |
| |
Re: Your indention and line spacing is messed up post the code properly and explain what works and where you have problems. | |
Re: We help you preferably to finalize your working or mostly working code, but if you are really stuck in some places on the way and show reasonable effort to debug those, we can give hints or warnings of bad approach to you. Basically we want to support members learning and … | |
Re: I understand the task as to see the final value (which would be 0 with infinite precission) with two precission of one_third: add_10_billion_times(one_third) - 10E9 / 3. | |
Re: I do not understand why you need to reallocate, when you are only removing letters and the size just shrinks if you do the deletions. And if you need to keep the original string, why not only keep letters which are not same as previous letter was in simple copy … | |
Re: My implementation is cute two two branch ifs and this is the trace of running the function with trace decorator two of you examples as input. | isomorphic ([4, [[3, 6], [], 7], [8]], [[[3]], 7, [[5, [9, 2], [[[[[4]], 2]]]]]]) | isomorphic (4, [[3]]) = False | = False … | |
Re: Use same kind of epsilon and absolute value 'floating point equality test' with zero to finish as in the lecturers root finding example (which I generalized little in http://www.daniweb.com/software-development/python/code/436392/example-of-bisection-search-for-monotonously-increasing-function-value) | |
Re: At least the lines 11 to 17 do not make any sense and should be deleted. Lines 46 - 48 are worse. You can not change the meaning of numbers by assignment. Shortly: everything is wrong. | |
Re: There does exist way, but this is usually kind of question which arrises, when new to programming people design their data structure badly, usually ignoring possibility of nested sequences like (('animal', ['duck', 'chicken', 'horse']), ('drinks', ['coke', 'tea', 'coffee'])) | |
Re: Here for comparison how you could do without the first code snippet the examples given and without re module. >>> import socket >>> [s for s in dir(socket) if 'host' in s.lower()] ['AI_NUMERICHOST', 'INADDR_ALLHOSTS_GROUP', 'NI_MAXHOST', 'NI_NUMERICHOST', 'gethostbyaddr', 'gethostbyname', 'gethostbyname_ex', 'gethostname'] >>> [s for s in dir(socket) if 'host' in s.lower() … | |
Re: Use " or """ quoting for strings containing single quotes. | |
Re: Post the relevant piece of code with suitable input data, expected results, explanation of the logic, error messages, how you tested it... | |
Re: >>> a = [0xFF,0xFF,0xFF,0xFF] >>> b = [~val for val in a] >>> b [-256, -256, -256, -256] >>> b = [~val & 0xFF for val in a] >>> b [0, 0, 0, 0] >>> | |
Re: I do not know yet, but you are asking the file name, but are not using it. | |
![]() | Re: Too late, I did it ;) You might want to add a spammer cleaned version of number to add to it, so we might reword the article little also for more positive tone. |
Re: You are using Python 3 aren't you? The code looks OK for me except I would return value from function, not print from there. Could you give the exact error message and your input. | |
![]() | Re: Hello, fellow MITx student, your balance decreases when you pay loan, doesn't it? I do not want to help more. ![]() |
Re: This could be usefull: http://docs.python.org/tutorial/controlflow.html |
The End.