3,386 Posted Topics

Member Avatar for gerswin

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 …

Member Avatar for vegaseat
0
305
Member Avatar for farhan69

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.

Member Avatar for farhan69
0
181
Member Avatar for siga

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.

Member Avatar for vegaseat
0
942
Member Avatar for Niner710

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.

Member Avatar for dashing.adamhughes
0
1K
Member Avatar for chinaexpert1

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**!

Member Avatar for TrustyTony
-1
254
Member Avatar for romes87

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

Member Avatar for TrustyTony
0
251
Member Avatar for padton

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 …

Member Avatar for snippsat
0
225
Member Avatar for aVar++
Member Avatar for Lucaci Andrew
0
234
Member Avatar for TrustyTony

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

Member Avatar for ZZucker
2
188
Member Avatar for BigPaw

If you run windows there at least is numpy, what you mean? http://www.lfd.uci.edu/~gohlke/pythonlibs/

Member Avatar for Lardmeister
0
699
Member Avatar for ZZucker

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 …

Member Avatar for TrustyTony
0
176
Member Avatar for sudipta.mml

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', …

Member Avatar for otengkwaku
0
232
Member Avatar for Octet

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 …

Member Avatar for Octet
0
180
Member Avatar for Fernando_1

print(2*'\n') at line 19 before results. Or change the line 20 print "\n\nThe sales amount is $", salesAmount

Member Avatar for vegaseat
0
219
Member Avatar for nitin1

How do you know your host is a geek? Because he asks you: "Do you like coffee exclusive or tea?"

Member Avatar for <M/>
0
204
Member Avatar for clouds_n_things

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

Member Avatar for clouds_n_things
0
131
Member Avatar for TrustyTony

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.

Member Avatar for TrustyTony
0
232
Member Avatar for padton

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

Member Avatar for TrustyTony
0
178
Member Avatar for TrustyTony

![circuit](/attachments/small/2/circuit.jpg "align-right") 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)

0
2K
Member Avatar for TrustyTony

![Lisp001](/attachments/small/2/Lisp001.jpg "align-left") ![Lisp002](/attachments/small/2/Lisp002.jpg "align-right") 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 …

0
627
Member Avatar for vegaseat

What kind of virus golt, as you are putting all values in parenthesis?

3
289
Member Avatar for ricepicker417
Member Avatar for Frensi

I can not run the code, after adding import and commenting out fonts I do not have, it fails with not existing TextBox.

Member Avatar for Lardmeister
0
237
Member Avatar for csk19

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 …

Member Avatar for Taywin
0
608
Member Avatar for giancan

No, I think. You must execute the command by yourself. wx is only for window management.

Member Avatar for sneekula
0
1K
Member Avatar for newbieha

Do not give ready answers vahids. Luckily your answer is not correct. The language is actually same as L(aa+bb+) (aa* == a+)

Member Avatar for TrustyTony
-2
78
Member Avatar for welshly_2010
Member Avatar for TrustyTony

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 …

0
314
Member Avatar for fheppell
Member Avatar for rev_ollie

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 …

Member Avatar for rev_ollie
0
4K
Member Avatar for sudipta.mml

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

Member Avatar for TrustyTony
0
471
Member Avatar for SumTingWong59

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

Member Avatar for TrustyTony
0
141
Member Avatar for z.n11

if c==3: if can not exist without statements, if you want to use place holder use `pass` if c==3: pass

Member Avatar for TrustyTony
0
103
Member Avatar for TrustyTony

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 …

Member Avatar for vegaseat
0
259
Member Avatar for Landoro

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" ;)

Member Avatar for Adak
0
200
Member Avatar for happymadman

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

Member Avatar for woooee
0
136
Member Avatar for chris99

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 …

Member Avatar for woooee
0
133
Member Avatar for Frensi

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

Member Avatar for TrustyTony
0
2K
Member Avatar for rbyrd
Member Avatar for rbyrd
0
138
Member Avatar for calder.hutchins

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

Member Avatar for calder.hutchins
0
155
Member Avatar for AutoPython

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 …

Member Avatar for nytman
3
1K
Member Avatar for padton
Member Avatar for TrustyTony
0
231
Member Avatar for RLS0812

> set/retrieve cookies. Why not cookielib? http://docs.python.org/2/library/cookielib.html#examples

Member Avatar for TrustyTony
0
235
Member Avatar for Jacklittle01

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.

Member Avatar for justinbellaa03
-4
89
Member Avatar for Jezza25
Member Avatar for TrustyTony
0
112
Member Avatar for aVar++
Member Avatar for Gribouillis

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 …

Member Avatar for Gribouillis
2
578
Member Avatar for vegaseat

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

Member Avatar for Ene Uran
3
804
Member Avatar for sym366
Member Avatar for vegaseat

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.

Member Avatar for Lardmeister
5
756

The End.