761 Posted Topics

Member Avatar for banannamoofin

[QUOTE=tonyjv;1516801]Why not? See my code snippet: [url]http://www.daniweb.com/hardware-and-software/microsoft-windows/windows-nt-2000-xp/threads/2934[/url][/QUOTE] Tonyjv: Is that the link you really intended? Seems not.

Member Avatar for TrustyTony
0
213
Member Avatar for sirpampos

The distance between two points on a plain is the square root of the sum of the squares of the x and y distances. ([URL="http://jwilson.coe.uga.edu/emt668/emt668.student.folders/headangela/essay1/pythagorean.html"]Pythagorean theorem[/URL]: "The square of the hypotenuse is equal to the sum of the squared of the other two sides") So you just need to calculate …

Member Avatar for sirpampos
0
119
Member Avatar for elbib84

I have two problems understanding: 1. You must use the (CODE) button to make sure that indent and line numbers are correct. Without indent, it is very hard in Python 2. Your data is too complicated to understand easily. Can you make up something very much shorter that has the …

Member Avatar for griswolf
0
151
Member Avatar for eskimo456

This is actually pretty common. There are two solutions: [LIST] [*]Good: figure out what part is needed by both Particle and Grid and put that into a third header. Now each can [ICODE]#include[/ICODE] that third header and there's no cycle [*]Less Good: Merge the two headers into one. There's no …

Member Avatar for mike_2000_17
0
122
Member Avatar for Zababa

Back in the days when computers used line printers to communicate, a carriage return actually caused the printer to push the carriage (print head) back all the way to the left. A line feed, on the other hand, caused the paper to advance by one line without moving the carriage. …

Member Avatar for Zababa
0
188
Member Avatar for alokdhari

There is no need to be angry when someone points out that you haven't done your homework before posting here: [URL="http://en.wikipedia.org/wiki/RTFM"]RTFM[/URL] actually works very well in Python. In addition to Google, let me suggest searching at [url]http://docs.python.org[/url]. I'll do it for you the first time. [URL="http://docs.python.org/search.html?q=deep+copy&check_keywords=yes&area=default"]Look here.[/URL] (8.17)

Member Avatar for alokdhari
0
211
Member Avatar for Sadun89

Rule of thumb: It takes about 1 month for a not-so-super intelligent person to "learn" a new programming language well enough to actually write a useful app. About 5 or 6 months later, if you are still using that language, you will look back on your early code and be …

Member Avatar for Sadun89
0
93
Member Avatar for ashrafu1

I'll assume this is a student exercise. What you need is a "global" function that issues 'the next' id. If your code is multithreaded, then you also need that your 'nextId()' function has a mutex or some other way to serialize access to the part that actually returns an ID. …

Member Avatar for griswolf
0
288
Member Avatar for figment56

Step One: Please in future post code using the (CODE) button, which gives lots of good effect for very very little effort. (Please also look for the 'thread is solved' link at the bottom and **after the thread is really solved** be sure to mark it solved: That, too, gives …

Member Avatar for figment56
0
254
Member Avatar for pichels

how about piping it through a pager? [iCODE]less -y20[/iCODE] will page 20 lines at a time.

Member Avatar for cfajohnson
0
408
Member Avatar for weblover
Member Avatar for Annuate

Have you heard of lex and yacc? (flex and bison if you want the GNU versions). Actually, for a basic calculator, just using the lexer is enough.

Member Avatar for rubberman
0
160
Member Avatar for WolfShield

The first think you need to do is connect to the server and figure out what to do next. [URL="http://www.crummy.com/software/BeautifulSoup/"]Beautiful Soup[/URL] helps with the second part. [URL="http://docs.python.org/library/urllib.html"]Urllib[/URL] and [URL="http://docs.python.org/library/urllib2.html"]urllib2[/URL] help with the first part. A quick web search came up with [URL="http://twill.idyll.org/"]twill[/URL] as a source of inspiration for how to …

Member Avatar for WolfShield
0
515
Member Avatar for spe_eddy

No. It uses [URL="http://en.wikipedia.org/wiki/Linear_regression"]linear regression[/URL] which (waving my hands broadly) amounts to finding the 'best possible' line through a set of points, and, given N-1 coordinates for a new point, guessing that the other coordinate puts the point on that line. With error bars. Least squares is a good but …

Member Avatar for spe_eddy
0
480
Member Avatar for indr

I suspect that you have not committed the first transaction, so it retains a lock, thus preventing the second transaction from beginning until the first transaction's lock is released... which will not happen until you commit it. [url]http://dev.mysql.com/doc/refman/5.0/en/[/url] : [QUOTE]By default, MySQL runs with autocommit mode enabled. This means that …

Member Avatar for indr
0
206
Member Avatar for blur blur

char is in fact a (very small) integer type. To convert the string of char to int, use atoi() or something similar.

Member Avatar for thekashyap
0
114
Member Avatar for ahappysadface

[QUOTE=ahappysadface;1510191]dear Group256 i am a student who is doing my project on python platform...according to my project i has to have a client server public chat code which is very similar to the one u have posted here. i am currently working on a code for this purpose but i …

Member Avatar for griswolf
0
112
Member Avatar for milanna1992

First, you must show us what code you have written so there is something to talk about. Please [thread=78223]Read This Before Posting[/thread]

Member Avatar for milanna1992
0
171
Member Avatar for shawntheking

Well, first you gotta show us some code, so there's something to talk about. Don't forget to use the (CODE) button.

Member Avatar for griswolf
0
55
Member Avatar for sdr001

Read the error message. It says that in main, you are trying to call a member function on an object that is not of type class. I suspect the error should actually tell you that the object is not of type [B]instance of[/B] class. In any case, that tells you …

Member Avatar for sdr001
0
117
Member Avatar for trume

There are many shells. Which one are you using? The normal meaning for PLUS parameters is" Return the sum of all the parameters", so the recursive way would be to [LIST] [*]return PLUS (first+second) rest of the parameters [*]Or calculate (i, i+1) for i in the proper range and return …

Member Avatar for griswolf
0
89
Member Avatar for hun1905
Member Avatar for pythonbegin

Umm. Too bad that the data you need to keep is in the shorter file. Still, if there is enough room to make a set of pairs from the large file, you can do it like this: [CODE]openfile2 = open(file2,'r') matchset = set((tuple(x.split()[:2]) for x in openfile2)) openfile1 = open(file1,'r') …

Member Avatar for griswolf
0
1K
Member Avatar for pink_872

Your code should just work because [iCODE]split()[/iCODE] should handle all kinds of white space including various newline characters. However, you can try [CODE]import string # ... for word in L.split(string.whitespace): if word: occurrenences[word] = occurrenences.get(word,0)+1 #...[/CODE] The extra test is [URL="http://docs.python.org/library/stdtypes.html#str.split"]because[/URL] when you specify the split characters, you get empty …

Member Avatar for griswolf
0
174
Member Avatar for kay21

In most hospitals it would be M:N of course. So you would have a doctor_patient table that associates any doctor with any patient. What else does it need to store? (hint: Do you want a new row every time the doctor sees the patient?). How do you handle patients who …

Member Avatar for kay21
0
1K
Member Avatar for sara90

Too many possible options to say the best way. Here is one way: For writing: write a header into the file, something like "<singly linked list follows>" iterate through the linked list writing one item per line write a footer into the file, something like "<end of singly linked list>" …

Member Avatar for template<>
0
121
Member Avatar for Fo.katia

You also need to know that strings have a method [ICODE]upper()[/ICODE] that puts them in upper case, and to know that [ICODE]somestring.join(list_of_strings)[/ICODE] puts [ICODE]somestring[/ICODE] between every element of the list. For instance[CODE]assert("name".upper() == "NAME") alist = ['hello','world'] assert(' '.join(alist) == "hello world")[/CODE] There is a reasonably elegant one-line solution, but …

Member Avatar for griswolf
0
144
Member Avatar for manish250

How would you like to display that information from a script? Unless you are willing to learn how to send fancy commands to the terminal, doing 'time remaining' means writing yet another line... Not a recipe for making pretty output.

Member Avatar for griswolf
0
205
Member Avatar for Acute

It provides the constant 1 for each row that matches the where clause. There is no where clause, so it gives a 1 for each row in the table.

Member Avatar for Acute
0
78
Member Avatar for spe_eddy

[ICODE]dayValues[/ICODE] is an empty list when you start, so [ICODE]dayValues[0][/ICODE] isn't yet in [ICODE]dayValues[/ICODE] and 0 is an index out of range. You probably want [ICODE]dayValues = [[]]*12 at line 4[/ICODE]

Member Avatar for TrustyTony
0
3K
Member Avatar for Emred_Skye

Consider using a pattern. What you want is to match [ICODE]pattern = "1\t1\t1"[/ICODE] and then translate the index in the row into the column number. Note that because of the tabs, [ICODE] column 1 is index 0 column 2 is index 3 column 3 is index 5 ... column N …

Member Avatar for griswolf
0
137
Member Avatar for sidlampard

Hint: most unix utilities accept a compact form multiple flags where you only give a single dash. The tar utility is so old that it doesn't even always require dashes at all.

Member Avatar for Potion
0
111
Member Avatar for bob_b

The pexpect documents ([URL="http://pexpect.sourceforge.net/pexpect.html"]here[/URL]) say[QUOTE]send(self, s) This sends a string to the child process. This returns the number of bytes written. If a log file was set then the data is also written to the log.[/QUOTE] So it appears you can set a logfile... and I'd expect that the logfile …

Member Avatar for griswolf
0
261
Member Avatar for Spiderpig085

Possible, probably. However neither legal nor ethical. Excerpted from the [URL="http://www.amazon.com/gp/help/customer/display.html/ref=footer_cou?nodeId=508088"]Amazon Conditions of Use[/URL] [QUOTE]Amazon grants you a limited license to access and make personal use of this site and not to download (other than page caching) or modify it, or any portion of it, except with express written consent …

Member Avatar for griswolf
0
409
Member Avatar for hughesadam_87

This should work. I have not actually tested that it even 'compiles', but you can see the pattern, right?[CODE]with open(theFileName,'r') as inbound: with open(theNewFileName, 'w') as outbound: state = 'skip' for line in inbound: if line.startswith('>>>>>Begin Processed Spectral Data'): state = 'write' continue if line.startswith('>>>>>End Processed Spectral Data'): state = …

Member Avatar for hughesadam_87
0
151
Member Avatar for lids05

I do not understand what you intend from your description. It is easy enough to merge the three scripts:[CODE]#do the first one path_to_script_one $parameters_for_script_one # do the second one path_to_script_two # maybe this one doesn't need params # etc[/CODE]If I guess correctly what you want, you could wrap it all …

Member Avatar for lids05
0
88
Member Avatar for joaep2

You can, of course put it anywhere and then update your PYTHONPATH to include it. Python packages on my mac live in [iCODE]/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site_packages[/iCODE] Beware that you may need to muck with one of the [iCODE].pth[/iCODE] files so the interpreter will correctly build its internal sys.path edit: Somehow, at some point, …

Member Avatar for joaep2
0
911
Member Avatar for lochnessmonster

As long as the code you show is in your header file, you'll be ok. You can also just put the implementation directly into the class declaration. Mostly for me, its a matter of aesthetics: If the inline function is a one- or two-liner, I tend to put it in …

Member Avatar for mike_2000_17
0
133
Member Avatar for flebber

Your problem is not clearly stated. Do you want to handle all files in the specified directory, or in [B]and below[/B] the specified directory? On line 13, I expect [icode]NameError: name 'walk' is not defined[/icode] It needs to be [URL="http://docs.python.org/library/os.html#os.walk"]os.walk()[/URL] ... but if you only want files in the exact …

Member Avatar for snippsat
0
2K
Member Avatar for failbot

What happens in push_back when the list is empty? How does what your code says do anything useful? Empty or not, where is T put into the list?

Member Avatar for failbot
0
350
Member Avatar for Geeko

You start by thinking about entities and their relationships. Then you draw a diagram according to the usual specifications that show those entities and relationships. Examples abound. Just glancing quickly at your spec, you will need tables for Patient, Doctor, Appointment (with foreign keys for Patient and Doctor). Is an …

Member Avatar for griswolf
0
1K
Member Avatar for snippetGirl

It is legal to define local functions that are effectively invisible outside the outer function. But I doubt that is what you mean? I think you are trying to say something about program flow. To "trap" an illegal division, I would raise an exception, and handle it in the main …

Member Avatar for Archenemie
0
123
Member Avatar for c+-
Member Avatar for Josue198s

Do you want a C program that acts like this Bourne shell script? Or a csh script that acts like this sh script? Either way, you need to start the work and post your code, possibly not yet running / compiling. Be sure to show the full errors if you …

Member Avatar for griswolf
-1
228
Member Avatar for lochnessmonster

Just off the top of my head: Constructors should result in a fully functional instance of the class. If you pass a filename to the constructor, you should use it in the constructor to populate the data. On the other hand, an empty array is also fully functional, so it …

Member Avatar for griswolf
0
439
Member Avatar for junrey laao

I suggest you start, as usual with the [thread=78060]Read me first[/thread] thread. Show some work and we are much more likely to take our own time to help you. Do you have to write code to do this homework? What is the source of the process data? I have to …

Member Avatar for griswolf
0
87
Member Avatar for rx21825

The following snippet shows you how to report for your first question. It is deliberately simple to understand, not compact.[CODE]filename = 'ccdata.csv' with open(filename,'r') as f: first_line = f.readline() labels = first_line.strip().split()[1:] # skip 'ID' (which may not be correct) counts = set() # this may be overkill? line_count = …

Member Avatar for rx21825
0
205
Member Avatar for tcl76

because Python doesn't distinguish int from just [URL="http://docs.python.org/library/functions.html#int"]cast to int[/URL]: [iCODE]long_result = int(some_string_with_hex_digits,16)[/iCODE]

Member Avatar for Gribouillis
0
5K
Member Avatar for vik.singh

You use a file based merge sort: [CODE]Repeat: Read in about half the memory's worth of data and sort it any way you like Write the sorted data to a temporary file Until all data has been read and sorted once Repeat: read and merge-sorted write the next two temp …

Member Avatar for Adak
0
137
Member Avatar for debasishgang7

your line 2 has a trailing [icode]read()[/icode] that should be removed before you try to do line 5

Member Avatar for richieking
0
141

The End.