3,386 Posted Topics

Member Avatar for vargabbaruah
Member Avatar for woooee
0
161
Member Avatar for techyworld

Latter causes uninitialized variable error if true variable is not defined. Python is case sensitive.

Member Avatar for TrustyTony
0
141
Member Avatar for Frensi

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: …

Member Avatar for TrustyTony
0
261
Member Avatar for ThePythonNoob

# 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 …

Member Avatar for ThePythonNoob
0
181
Member Avatar for findlay
Member Avatar for Kerma

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.

Member Avatar for woooee
0
305
Member Avatar for Mogworld937
Member Avatar for dean.ong.14

All of us have been new once, it is not sin. Just take one step at time and test your code.

Member Avatar for dean.ong.14
0
137
Member Avatar for Mitch275

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)]

Member Avatar for TrustyTony
0
180
Member Avatar for valorien

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])

Member Avatar for valorien
0
152
Member Avatar for Wire.Crisis
Member Avatar for Lardmeister
0
408
Member Avatar for rmbrown09

mark_sentance is undefined, alter_list is never called. Why only slice of 5 news, how long they are? You call them row.

Member Avatar for rmbrown09
0
161
Member Avatar for Kerry W

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 …

Member Avatar for ~s.o.s~
0
256
Member Avatar for elbarto

Could be usefull also, if you do not mind switching to QT: http://sourceforge.net/projects/pythoncad/

Member Avatar for TrustyTony
0
2K
Member Avatar for nyxie

Did you try the web server script from http://twistedmatrix.com/trac/ .

Member Avatar for abc0502
0
154
Member Avatar for dtripath
Member Avatar for vegaseat
0
129
Member Avatar for s123456

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.

Member Avatar for s123456
0
435
Member Avatar for pauldespre

... and if it is really main function you should call it only once from end of the module.

Member Avatar for TrustyTony
0
147
Member Avatar for La:)

Give error message and relevant inputs with problematic code and explain how the output/result differ from your expectations.

Member Avatar for abc0502
0
1K
Member Avatar for doobz
Member Avatar for woooee
0
761
Member Avatar for TrustyTony

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 …

Member Avatar for caperjack
0
263
Member Avatar for sgeep
Member Avatar for TrustyTony
0
837
Member Avatar for vegaseat

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?

Member Avatar for rubik-pypol
3
396
Member Avatar for syeda amna

That command is for shell/cmd.exe (WindowKey-R cmd <enter key>) not to python read-eval-print loop of interaction aka Python prompt (>>>)

Member Avatar for syeda amna
1
585
Member Avatar for Dani

>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

Member Avatar for L7Sqr
3
1K
Member Avatar for james5050

Write down how you do it yourself step by step, then write program for computer to do same.

Member Avatar for vegaseat
0
843
Member Avatar for mickeyVeliki
Member Avatar for robert.montgomery.75054
Member Avatar for glenwill101

Use new or old C style formatting: https://pythonadventures.wordpress.com/2011/04/04/new-string-formatting-syntax/

Member Avatar for Gribouillis
0
127
Member Avatar for Lucaci Andrew

http://www.daniweb.com/community-center/daniweb-community-feedback/threads/436270/daniweb-1000000-members

Member Avatar for happygeek
0
166
Member Avatar for mathews123

Think what would be the exit condition of the loop according to task. How could you express it as **continueing** condition of while?

Member Avatar for deceptikon
0
191
Member Avatar for TrustyTony

Now finally you warn discarding the post in the middle by leaving to other Internet page, thank you!

Member Avatar for TrustyTony
0
163
Member Avatar for TrustyTony
Member Avatar for adil.mahmud.choudhury

Your indention and line spacing is messed up post the code properly and explain what works and where you have problems.

Member Avatar for woooee
0
180
Member Avatar for Batcher

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 …

Member Avatar for TrustyTony
0
185
Member Avatar for Vaspar

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.

Member Avatar for TrustyTony
0
258
Member Avatar for ShEeRMiLiTaNt

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 …

Member Avatar for vijayan121
0
2K
Member Avatar for compscihelp

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 …

Member Avatar for compscihelp
0
205
Member Avatar for Eridanus

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)

Member Avatar for amRx1
0
1K
Member Avatar for Jacklittle01

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.

Member Avatar for TrustyTony
0
193
Member Avatar for whoisstanley

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']))

Member Avatar for Lardmeister
0
185
Member Avatar for Gribouillis

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() …

Member Avatar for TrustyTony
2
502
Member Avatar for PeteB247
Member Avatar for danikabhai

Post the relevant piece of code with suitable input data, expected results, explanation of the logic, error messages, how you tested it...

Member Avatar for danikabhai
0
114
Member Avatar for Niner710

>>> 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] >>>

Member Avatar for TrustyTony
0
80
Member Avatar for sym366
Member Avatar for Xantipius
0
1K
Member Avatar for iamthwee

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.

Member Avatar for Ezzaral
0
325
Member Avatar for nUmbdA

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.

Member Avatar for glenwill101
0
593
Member Avatar for johnpaul.denton

Hello, fellow MITx student, your balance decreases when you pay loan, doesn't it? I do not want to help more.

Member Avatar for johnpaul.denton
0
72
Member Avatar for combiana7
Member Avatar for Lardmeister
0
97

The End.