761 Posted Topics
Re: [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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. … | |
Re: 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) | |
Re: 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 … | |
Re: 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. … | |
Re: 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 … | |
Re: how about piping it through a pager? [iCODE]less -y20[/iCODE] will page 20 lines at a time. | |
Re: both sed and (g)awk can handle this with reasonable ease. | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: char is in fact a (very small) integer type. To convert the string of char to int, use atoi() or something similar. | |
Re: [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 … | |
Re: 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] | |
Re: Well, first you gotta show us some code, so there's something to talk about. Don't forget to use the (CODE) button. | |
Re: 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 … | |
Re: 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 … | |
Re: Where is your code that is not working? Please be sure to use the (CODE) button! | |
Re: 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') … | |
Re: 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 … | |
Re: 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 … | |
Re: 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>" … | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: [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] | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 = … | |
Re: 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 … | |
Re: 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, … | |
Re: 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 … | |
Re: 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 … | |
Re: 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? | |
Re: 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 … | |
Re: 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 … | |
![]() | Re: 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 … |
Re: 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 … | |
Re: 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 … | |
Re: 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 = … | |
Re: 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] | |
Re: 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 … | |
Re: your line 2 has a trailing [icode]read()[/icode] that should be removed before you try to do line 5 |
The End.