75 Posted Topics
Re: Can you search for the d.complex numbers? If you can, you can get a slice of the list. [CODE] # Let 'L' be your list. newL = L[ L.index(d.complex.1) : L.index(d.complex.2) ] [/CODE] | |
Re: Are you trying to read an HTML file from the web? You may want to look at the curl library ( [url]http://www.libcurl.org/[/url] ). It will allow you to collect data directly from a URL in a pretty user-friendly fashion. [CODE] /* Downloads a webpage's html and saves it to a … | |
Re: You can not pass an expression to a function, since the expression would be evaluated right before the function is called, and you would not be able to repeat it. On the other hand, you can indeed use a for loop. Hopefully that's what you're looking for. [CODE] for ( … | |
Re: On line 51 of your main program, you are counting the number of times the last number you entered occurred, and checking to see if that's equal to ten. Try rewriting the for loop that starts on line 49 as a while loop that continues as long as [ICODE]ages.countOccurrences(10) > … | |
Re: Do as kaoni317 suggests, but specify the -f flag. [icode]rm -f *.o target.exe target[/icode] This will stop make from terminating just because one of the files don't exist. | |
Re: If you want to process the file one line at a time, here's a loop that will do that for you. [CODE] myline = "dummy_string" while myline != "": myline = fin.readline() # do whatever you want, one line at a time [/CODE] Just handle each line as it comes … | |
Re: The variables you are using are all locally defined for the main function. The value that a local variable starts with when running the program is undefined. You need to make sure you initialize them to some known value (in this case, you should set them all to zero) before … | |
Re: I'm on Ubuntu 9.04 and experiencing no trouble at all. Have you tried changing your package server? You can go to System->Software Sources and pick a different server to see if that does anything interesting. It might be your local repository is down. If that doesn't work, you can always … | |
Re: Aha! I got it. See, you're pushing a copy of your entire graph structure on the stack every time you call a function with g. Your definitions need to look more like this. [CODE] void dfs_visit( graph *g, int u ); void dfs( graph *g ); [/CODE] And when you … | |
Re: Are you calling fclose when you're done with the file? fclose will make sure that all data that's left in the stream will be pushed to the file its pointing to before the program shuts down. It looks like data is getting stuck in the stream before the program terminates … | |
Re: An array can only be initialized when it is declared. Once it's been declared, you have to store the data using strcpy or some such thing. [CODE] /* To initialize during declaration. */ sndex[6][9] = {"BFPV","CGJKQSXZ",...}; /* To store during runtime. */ strncpy( sndex[0], "BFPZ", 8 ); [/CODE] As a … | |
Re: There are two ways to do this. The first way is to turn any directory with important python code into a module. This can be done by simply adding a file named '__init__.py' to the folder. Then, you can import the code using the from construction. [CODE] from uselib import … | |
Re: That's excellent reasoning, but unfortunately (and against primary intuition), that's not how encapsulation works in Java. See, when a member variable/method is declared private, it means that it can not be accessed by the code in *other* classes. However, there is nothing stopping a function in one ExpertPlayer from accessing … | |
Re: Well, this was probably a bad idea, but I went ahead and wrote you that example you asked for because I thought it would be fun. Needless to say, it's particularly trivial compared to what you're trying to do, but hopefully you can see the thought process that went behind … | |
Re: Your code executes the line 'rand() % 0', which is a divide-by-0 error. Start your for loop at i=1 or something of that nature. | |
Re: [QUOTE=abhimanipal;1132782]According to me , this should be the order of evaluation b==0, which gives false & the expression becomes a=a==0 this should again give false & the expression should become a=0 thereby the value of a should be 0[/QUOTE] Actually, what's happening is [icode] a = (a==b==0) [/icode] which is … | |
Re: Why didn't you go back and edit your post? It's impossible to read Python without indentation, you know. Regardless, I found your problem and fixed it up for you. [CODE=python] #!/bin/usr/env python import os import sys import glob count = 0 file_list = glob.glob("fam*.aln") for file in file_list: fileOPEN = … | |
Re: [QUOTE=sujithy15;1132620]but what difference does it create in allocating memory to a class instance dynamically or during compile time? here what is the advantage of such memory allocation ?[/QUOTE] A program that allocates memory during runtime is more scalable. Let's say you're making a spreadsheet application, and each cell is an … | |
Re: What platform are you on? Assuming you're on windows, it sounds like you're typing bcc32 in the 'run a command' box. If that's the case, try typing 'cmd' in that dialog to bring up the black terminal, and then try bcc32. Without knowing the platform or exactly what you're doing, … | |
Re: Your professor is sadistic? Well, I can be sadistic too. [CODE=c] #include <stdlib.h> #include <stdio.h> int reverse( int code, char *start, int diff ); int main( void ) { char c; int diff; /* Figure out the size of runtime stack blocks. */ diff = reverse( 1, NULL, 0 ); … | |
Re: convert_alpha() returns a new surface that you need to save over your old one. [CODE] image = pygame.image.load('example.png') image = image.convert_alpha() [/CODE] It's much more efficient than setting a colorkey because it converts the image to Pygame's native blitting format. | |
Re: When pressing Escape, it sends the escape character to the program. Unfortunately, curses ignores that when you enable KEYPAD. See, when you press the various function keys, arrow keys, etc, each of those codes start with the escape character. So when curses sees an escape character, it assumes you pressed … | |
Re: In patient.java... [CODE] void setName(String string) { string = this.name; } [/CODE] Are you sure you don't have that backwards? That would explain why you're getting a null name. Your setID does the same thing. | |
Re: The only thing I can think of is to route the output to a file. [ICODE] system("uname > foo"); [/ICODE] where you can use fgets to get the data on the file you want, and then delete the file when you're done with it. Hope this helps. | |
Re: Depending on which version of Windows you have, you should be able to let Ubuntu automatically resize the partition for you for you - I had Vista at the time and it worked pretty cleanly. When you reach the step about guided partitioning, one option allows you to size up … |
The End.