3,386 Posted Topics
Re: You can make set of lines in file two and one and difference is the lines to add to file two. If order does not matter you can add those line at end of file two by reopening in append mode the file two, otherwise add to lines already read … | |
Re: You forgot to put in the code you tried so far. You might want to check http://www.daniweb.com/software-development/python/code/293490/text-file-based-information-access-by-field-name-and-number even it is maybe overkill in your simple case. | |
Re: You are not using the parameters to methods of JTrans, but you are using magic constants instead. You can not use module as function like you are trying in line 35. | |
Re: What your request seems to boil to is page = 128 block = 0 print sorted(set(range(16)) - set(pandasDF[pandasDF['Page'] == page]['LogBlk'] == block]['BayFail'])) But I have no means to check it. | |
Re: I am currently registered to the course after completion of the MITx 6.001. You can discuss on edx course Discussion forum once the course starts or if the topics are valid for general discussion here in Daniweb. Do remember to honor the **Honor Code**! | |
Re: You might find this my code snippet useful as example: http://www.daniweb.com/software-development/python/code/289548/picking-piece-of-string-between-separators | |
Re: You have only one sum Lucaci, so I do not think that will work. num_files = 3 base = 'text%i.txt' with open("SumFile.csv", "w") as sf: sf.write(',\n'.join('%6.20f' % sum(float(num.strip()) for num in lines) for lines in zip(*(open(base % n, 'r').readlines() for n in range(1, num_files + 1)) ) ) ) print … | |
Re: Look articles on sorting algorithm based on swapping adjacent items. | |
Notice that if you negate a boolean value with `not` in comparison with other boolean value or similar, you should put it inside a pair of parenthesis, otherwise you get syntax error: >>> 0 == not 1 SyntaxError: invalid syntax >>> 0 == (not 1) True >>> | |
Re: If you run windows there at least is numpy, what you mean? http://www.lfd.uci.edu/~gohlke/pythonlibs/ | |
Re: You probably solved it by now. I also reminded little about J. I got this basically from imitation of documentation example. t =: _4 [\ F cs =: ,.@; +/ cs t ┌───────────────────────────────────────────────────────┐ │ 0 1 1 2│ │ 3 5 8 13│ │ 21 34 55 89│ │ 144 … | |
Re: You are not using the imports from the first 4 lines so those do not count as effort. To generate strings with incrementing number you can use: names = ['test%i.data%i' % (m,n) for m in range(1, 5) for n in range(1,3)] print names """Output: ['test1.data1', 'test1.data2', 'test2.data1', 'test2.data2', 'test3.data1', 'test3.data2', … | |
Re: I would try to learn to use functions for clarity, import subprocess is superfluous and unused as only separaterly imported Popen is used. Try..except suggestion for opening suggested by chriswelborn is also good one. Untested code to give the idea (those functions look nice to have, so let's also enable … | |
Re: print(2*'\n') at line 19 before results. Or change the line 20 print "\n\nThe sales amount is $", salesAmount | |
Re: How do you know your host is a geek? Because he asks you: "Do you like coffee exclusive or tea?" | |
Re: Your functions are duplicates, you only need one to return the file names. I do not understand your question. def video_game(game_dir='/SNES/SNES Roms', extensions=('.src','srm')): return [file_name for file_name in os.listdir(game_dir) if data.endswith(extensions)] | |
I posted one Scheme code to Legacy Languages, and noticed that the formating for Lisp style quoting (single single quote or back quote before) does not function. I know you have more urgent things to consider, but you could put it in your list, Dani. | |
Re: >m = sqrt((((a2s1.data-a2s0.data)**2))+((a1s1.data**2-a1s0.data)**2)) This look like same as `math.hypot` function. for at line 21 is missing :, you could consider preparing deltas before writing I think you should also close the files, even if it is not strictly required in Python. 60 files is anyway lot to leave hanging around … | |
 Here is a version in Python of program from classic Lisp book (see http://www.daniweb.com/software-development/legacy-languages/code/446235/simple-scheme-functions-for-finding-impedance-for-norvigs-implementation for the details) for calculating impedance of a circuit. (Example circuit with 1MOhm like in the book's code not like in diagram) | |
  I did translation to minimal Scheme implementation of Norvig written in Python (http://www.daniweb.com/software-development/python/threads/359370/norvig-an-even-better-lisp-interpreter-in-python) of the impedance code defined in classic book **Lisp by *Patric Henry Winston* and *Berthold Klaus Paul Horn*** from year 1981 (first computer book I ever bought). Errata: diagram has 10 MOhm when … | |
Re: What kind of virus golt, as you are putting all values in parenthesis? | |
Re: Show your code, and tell us what is not clear. | |
Re: I can not run the code, after adding import and commenting out fonts I do not have, it fails with not existing TextBox. | |
Re: Coded it half optimized in Python and it works in there in 17.6 ms, little more optimized in 4.67 ms. You only need to keep best solution and go down in inner loop based on best solution so far. My program stops going down with loop counters at 953 and … | |
Re: No, I think. You must execute the command by yourself. wx is only for window management. | |
Re: Do not give ready answers vahids. Luckily your answer is not correct. The language is actually same as L(aa+bb+) (aa* == a+) | |
Re: What you have problem with, could you post also your effort? | |
Here is code, which you can play with before installing and using the [superior blist package from pypi](http://pypi.python.org/pypi/blist/). I did it as therapy after doing programming test answer using zillion of setters and getters. Motivation is basically to show why you should use properties after you need them and attribute … | |
Re: line 6 should be inside the with block | |
Re: Somethin like this? for data in "7e001090007d33a200408b2e0c2db70100160057637e001090007d33a2004089e04a569d010016003885".split('7e'): if data[4:6] == '90': print "==========================" print "Found Packet: 7e%s" % data print "Packet Type = ZgBee RX Packet" AH = data [10:18] AL = data [18:26] print "Device Address = ", AH, AL TH = data [34:36] TL = data [38:40] THc … | |
Re: After bit googling around, this looks like nice, medium taugh scientific paper digging deep in subject: http://www.cse.msu.edu/~cse891/Sect001/notes_alignment.pdf | |
Re: def is_full(board): return all(p in tuple('xo') for p in board) or def is_full(board): return not ''.join(str(p) for p in board).strip('xo') | |
Re: if c==3: if can not exist without statements, if you want to use place holder use `pass` if c==3: pass | |
This example program of using the multiprocessing is crashing my i7 4 core windows7 64 bit computer (32 bit enthought Python 2.7), but is running fine in virtual machine Ubuntu with 4 cores assigned. Can anyone run it in their commputer in Windows7. My system memory (8 GB) is totally … | |
Re: Concrats! Now that you have logic right, why not practise some commenting and/or changing the variable names descriptive? Maybe also you could find little better indention standard as I find for example indention of the for loop lines 22-56 kind of "interesting" ;) | |
Re: Can not say I can read your code it being 100+ lines, at least I can not find time for it now. Here is my own Caesar cipher (in beginning of thread is the single line version, but it is for practice, not for use): http://www.daniweb.com/software-development/python/code/380051/one-line-caesar#post1637147 | |
Re: We can not know as we have not even the error message you get and can not run the code as it is not runnable. But as it is only syntax error in previous line, it is easy to see by just trying to check the syntax. One ) is … | |
Re: It does not make sense to substract function from value (in `__init__` actually you are overwriting this function with current time, so you can not call it anyway): self.time_elapsed = time.clock() - self.clock_start | |
![]() | Re: Are you sure that you are inserting numbers, not strings? ![]() |
Re: You seem to have some bug, basically you decode with 26 - key to get original message. It is better to learn to use functions. #Python 2 compatibility from __future__ import print_function try: input = raw_input except: pass def caesar(message, key): coded_message = "" for ch in message.lower(): code_val = … | |
Re: Here is little modified version to be more evident what it does: [CODE]## run with Python 3 from command line or double click import threading import time def TimeProcess(): while not threadBreak: print (time.time() - startTime) input(""" Press enter key to start timer, after some time push enter again to … | |
Re: use makedirs http://www.tutorialspoint.com/python/os_makedirs.htm | |
Re: > set/retrieve cookies. Why not cookielib? http://docs.python.org/2/library/cookielib.html#examples | |
Re: You would use global variables only when forced to. If your code is not OO, the general way is to pass variables as parameters to the functions. For OO you would change the object's attribute's values instead of returning value. | |
Re: Why you must convert it to float, how are you using it? You can not use 'Car' same as float. | |
Re: Check if the position is occupied in your board. | |
Re: But: [CODE]class ConstSequence(object): "Read-only wrapper around a sequence type instance" def __init__(self, seq): if isinstance(seq, ConstSequence): seq = seq._adaptee self._adaptee = seq def __getitem__(self, key): import types if isinstance(key, types.SliceType): return ConstSequence(self._adaptee[key]) else: return self._adaptee[key] def __len__(self): return len(self._adaptee) def __contains__(self, key): return key in self._adaptee def __iter__(self): return (x … | |
Re: You can test [B]in[/B] for any iterable (sequences, generators and also set): [CODE]>>> t = (1, 2,3) >>> 1 in t True >>> 5 in t False >>> t = '1231231231' >>> 1 in t Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> 1 in t TypeError: … | |
Re: You forgot your effort for finding the answer. | |
Re: Quite speed demon you got (you beat my new Core i7-3770 Windows7 times)! I got however (11.5, 10.7) as result to line 107. |
The End.