3,386 Posted Topics

Member Avatar for L7Sqr

I think better approach would be to just 'transparentely add +'. I mean that you do not have substraction routine but enter adding with negation flag set for number scanner. Then you just toggle the negation flag for minus ignoring plusses. That could be handled by suffiently competent number parser. …

Member Avatar for happyuk
2
6K
Member Avatar for Diamonddrake

For another timing idea, see my [work and pause time timer in Python language](http://www.daniweb.com/software-development/python/code/373687/work-and-pause-timer). Maybe anybody want to do similar thing in C#? Or you could transfer it to Iron Python for .Net environment.

Member Avatar for kplcjl
1
3K
Member Avatar for gmorcan

class average should update by accumulating the initialized sum by += not overwrite variable by =. You should take probably also average, not sum. Here little more advanced version for averaging total items. values = [item for value in my_dict.items() for item in value] average = float(sum(values)) / len(values)

Member Avatar for woooee
0
265
Member Avatar for mkweska

> classChosen = raw_input('Choose your class: ') > if classChosen == int(1): This will never be true as classChosen is string, not integer. It is clearer also not to use int without purpose. classChosen = raw_input('Choose your class: ') if classChosen == '1':

Member Avatar for Schol-R-LEA
0
219
Member Avatar for M.S.

Provided your code is correct, this is how I could clean it up (unchecked): def ID_check(ID_code): if (all(x==ID_code[0] for x in ID_code)) or len(ID_code) < 8 or len(ID_code) > 10 : return False ID_code = ('00'+ID_code)[-10:] intlist = [int(i) for i in ID_code] control = sum(intlist[ind] * (10 - ind) …

Member Avatar for M.S.
0
2K
Member Avatar for krystosan

Google is your friend: http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html

Member Avatar for krystosan
0
116
Member Avatar for HoneyBadger
Member Avatar for vegaseat
0
337
Member Avatar for giancan

http://stackoverflow.com/questions/3837426/python-set-intersection-question

Member Avatar for giancan
0
394
Member Avatar for dirtydit27

Use second parameter of split to limit splits to two. >>> '1958 MGA Twin Cam'.split(None, 2) ['1958', 'MGA', 'Twin Cam'] >>> '1961 Corvair'.split(None, 2) ['1961', 'Corvair'] >>>

Member Avatar for snippsat
0
380
Member Avatar for Siberian

No only listed directories are checked. Of course the directory can be package and then it is imported normally.

Member Avatar for Siberian
0
1K
Member Avatar for lancevo3
Member Avatar for TrustyTony
0
278
Member Avatar for debasishgang7
Member Avatar for Gubbei

> double the size of the picture (Chapter 4.3). Not enough effort to convince me at least, not able to copy given code.

Member Avatar for bumsfeld
0
229
Member Avatar for clouds_n_things
Member Avatar for asaidi

What you have your path now? Also check about [shebang](http://en.wikipedia.org/wiki/Shebang_%28Unix%29)

Member Avatar for asaidi
0
64
Member Avatar for flebber

The number of flips on average is first_flip + flips + final_flip = flips + 2: from __future__ import division from random import randint flips = 0 trials = 10000 for trial in range(trials): first_flip = randint(0, 1) while randint(0, 1) == first_flip: flips += 1 # flips between print …

Member Avatar for flebber
0
2K
Member Avatar for jeremywduncan

Your menu function with returnig input fuction is quite nice. Your class definition seems to be wrong however as some mehods have not self as first parameter.

Member Avatar for woooee
0
271
Member Avatar for krystosan

lines 5 and 6 have no effect as they set local variables and do not use them. Setters and getters are not considered very pythonic. Prefered way is to use attributes and replace those with calculated properties only after need arrices. However it is common that teachers of courses require …

Member Avatar for woooee
0
240
Member Avatar for krystosan
Member Avatar for james.lu.75491856

You must not use directly use list for parameter default but use None as default: f = open("relay.in").read().split() cows = f[0] data = dict(enumerate(f[1:],start=1)) print data nonloopy = [] loopy = [] def isloopy(cownum,data,did=None): if did == None: did=[] print " ",cownum,did cownum = int(cownum) if cownum in nonloopy: return …

Member Avatar for woooee
0
591
Member Avatar for delta_frost

Your main code is not protected for importing, which multiprocessing module uses, this works: import multiprocessing def cracker(): print "Hello" return if __name__ == '__main__': procs = [] for i in range(8): p = multiprocessing.Process(target = cracker) procs.append(p) p.start() for p in procs: p.join()

Member Avatar for delta_frost
0
597
Member Avatar for $Tweety$
Member Avatar for Fernando_1

looking the long lists of variable names declared global seems strange. If everything is global why you use functions? The function use looks otherwice nice, but reconsider the parameters of them.

Member Avatar for woooee
0
315
Member Avatar for ajit.nayak3

You are trying to use simultanously on single file in two modes, which does not make any sense: > inputCSV = open(r'test.csv', 'rb') outputCSV = open(r'test1.csv', 'wb+') appendCSV = open(r'test1.csv', 'ab+')

Member Avatar for TrustyTony
0
257
Member Avatar for paulmal

8x8 array filled with fields assigned. Could be done with standard search. Assignement is really 3 fields as last is fixed by the third choice. So you have depth three search tree (choosing 2 of 8 teams, 2 of 6 teams and 2 of 4 teams) for each play.

Member Avatar for Gribouillis
0
142
Member Avatar for nytman
Member Avatar for Frensi
Member Avatar for sepp2k
0
11K
Member Avatar for kindergeek

Maybe more this http://www.daniweb.com/software-development/python/code/356952/pep8-quadratic-equations-solver

Member Avatar for Lardmeister
0
326
Member Avatar for MasterHacker110

Did you check the code snippets like my http://www.daniweb.com/software-development/python/code/380881/python-3-and-python-2-send-email-through-gmail

Member Avatar for TrustyTony
0
181
Member Avatar for syfr
Member Avatar for Gribouillis
0
960
Member Avatar for aVar++

You do not need loop to find number of combinations if you use math.factorial function: http://www.mathwords.com/c/combination_formula.htm If you want to do more efficient way, you can do loop upto the r value (see that both numerator and denominator have r values)

Member Avatar for Ene Uran
0
289
Member Avatar for dp121307

You are not actualy using the class anywhere, also you should say f1 + f2, not f1.\__add__(f2), it is same but less readable. f1 = Complex(R1, I1) print (f1, "+", f2, "=", f1 + f2) The print statement needs a `__repr__` method for the print statement in Python 2, you …

Member Avatar for TrustyTony
0
488
Member Avatar for Diogo Martinho

Like would you not just answer four times more solutions when doing a query? Anyway little Googling gives you: http://old.nabble.com/Re%3A-find-n-solutions-p27835812.html

Member Avatar for TrustyTony
0
273
Member Avatar for scubastevie

Looks you have only one number per line so you do not need to loop line by line. I am not going ot show directly how to make them **int** egers instead of **str** ings, but this gets you the strings: number_strings = list(f)

Member Avatar for Lucaci Andrew
0
228
Member Avatar for sudipta.mml

Maybe you should plot them separately with[ subplot](http://matlab.izmiran.ru/help/techdoc/ref/subplot.html) then?

Member Avatar for TrustyTony
0
406
Member Avatar for gangster88

You are welcome to do one, or hire a programmer if you need one for real. But learning requires for you to do honest try yourself. Also the rules of Daniweb tells the same. Also you are welcome to start new threads, but do not continue old threads if your …

Member Avatar for TrustyTony
0
2K
Member Avatar for jeremywduncan

You might want to see my anagram code snippets, simplest handling one word anagrams only is here http://www.daniweb.com/software-development/python/code/285434/super-simple-one-word-anagrams

Member Avatar for TrustyTony
-1
784
Member Avatar for ichi0915

I think you are better to figure it yourself and honor the[ Honor Code](https://www.edx.org/honor) Luck with MITx 6.00x, just finished it myself as a refresher.

Member Avatar for TrustyTony
0
168
Member Avatar for omer.tzuk

Looks like the module you are importing should deal with LaTex http://cxc.cfa.harvard.edu/contrib/asciitable/#reading-tables

Member Avatar for TrustyTony
0
216
Member Avatar for cwarn23

Considering user badges have allmost the required information, it could be possible that text version could contain the data you request (or Dani could put them there). Just untested idea.

Member Avatar for riahc3
1
757
Member Avatar for superbhimanshu
Member Avatar for Fernando_1

First of all you do not need the first 20 lines, it is clearer to use the messages directly in were they are used, global variables/constants are bad idea (with few exceptions to rule). You can find this True when you see what you are doing at line 60 (vs …

Member Avatar for woooee
0
179
Member Avatar for amweasel

see http://www.daniweb.com/software-development/python/code/425727/goofy-sentence-generator and http://www.daniweb.com/software-development/python/code/364647/jail-input-and-looping-exercise

Member Avatar for amweasel
0
469
Member Avatar for TrustyTony

Here is my celebration post for entering level 3 in Project Euler. Again I left in my debug prints. I am in process of adapting myself to new .format style of formatting. I have commented out the prints though to get visible the running time of the functions own action. …

Member Avatar for TrustyTony
0
706
Member Avatar for dp121307

I do not see you updating the incorrect tries count, and you are doing same test three times in lines 15-19. A is defined but not used, and it does not look like class name even it is Capitalized. Also the code variable is not used. Are you sure that …

Member Avatar for woooee
0
2K
Member Avatar for HiHe

Related code of mine to help the Dani's related article search: http://www.daniweb.com/software-development/python/code/436392/example-of-bisection-search-for-monotonously-increasing-function-value There we do the bisection mathematically from function instead of ready value list.

Member Avatar for TrustyTony
3
636
Member Avatar for MartinPB

Can you get error message you are getting? Doesn't the fileinput work? http://www.daniweb.com/software-development/python/code/383201/fileinput-from-files-ignoring-incorrect-ones

Member Avatar for TrustyTony
0
1K
Member Avatar for lancevo3

val is a string and it is always greater than integer value i, because the name 'int' is before in alphabet compared to 'str'. So loop never terminates.

Member Avatar for lancevo3
0
147
Member Avatar for krystosan

OK, but you got some unnecessary love affair with the [], maybe because we are discussing about list comprehensions. But you can do with only generator expressions instead feeding the join method. Instead of print '\n'.join(["%d %s" % pair for pair in enumerate(names)]) You can use print '\n'.join("%d %s" % …

Member Avatar for vegaseat
0
200
Member Avatar for toldav

You only do a loop calling the chkconfig command, better not to reimplement it in Python.

Member Avatar for TrustyTony
0
114

The End.