3,386 Posted Topics
Re: 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. … | |
Re: 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. | |
Re: 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) | |
Re: > 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': | |
Re: 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) … | |
Re: Google is your friend: http://timgolden.me.uk/python/win32_how_do_i/get-the-owner-of-a-file.html | |
Re: Installing the wxGlade package also installs the wxPython for you. | |
Re: http://stackoverflow.com/questions/3837426/python-set-intersection-question | |
Re: 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'] >>> | |
Re: No only listed directories are checked. Of course the directory can be package and then it is imported normally. | |
Re: http://stackoverflow.com/questions/9275954/nose-test-freezing-at-raw-input | |
Re: http://www.diveintopython.net/xml_processing/ | |
Re: > double the size of the picture (Chapter 4.3). Not enough effort to convince me at least, not able to copy given code. | |
Re: readline**s**() like has been said or only `passFile` | |
Re: What you have your path now? Also check about [shebang](http://en.wikipedia.org/wiki/Shebang_%28Unix%29) | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: http://pymotw.com/2/argparse/ | |
Re: 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 … | |
Re: 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() | |
| |
Re: 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. | |
Re: 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+') | |
Re: 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. | |
Re: Are you using list or dictionary? | |
Re: range value should be integer: for tile_x in range(0, int(image_width/width)): | |
Re: Maybe more this http://www.daniweb.com/software-development/python/code/356952/pep8-quadratic-equations-solver | |
Re: 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 | |
Re: Using some helper functions could also help to keep your thoughts straight. | |
Re: 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) | |
Re: 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 … | |
Re: 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 | |
Re: 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) | |
Re: Maybe you should plot them separately with[ subplot](http://matlab.izmiran.ru/help/techdoc/ref/subplot.html) then? | |
Re: 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 … | |
Re: 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 | |
Re: 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. | |
Re: Looks like the module you are importing should deal with LaTex http://cxc.cfa.harvard.edu/contrib/asciitable/#reading-tables | |
Re: 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. | |
Re: use the key parameter for sort. | |
Re: 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 … | |
Re: 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 | |
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. … | |
Re: 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 … | |
Re: 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. | |
Re: 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 | |
Re: 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. | |
Re: 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" % … | |
Re: You only do a loop calling the chkconfig command, better not to reimplement it in Python. |
The End.