1,359 Posted Topics
Re: WolfShield: You've omitted some crucial details here, starting with, what GUI library you're using (I'd normally assume TkInter, since that's bundled with Python, but this doesn't seem like Python/Tk code). While it is not exactly relevant to the code section in question, it does make it harder to judge where … | |
I am making a last-ditch effort to get Django 1.3 configured to talk to SQL Server (both running on the same Windows 7 system), before I have to make a final decision whether to move on to ASP.NET instead. I am using PyODBC (I had tried PyMSSQL but was recommended … | |
Re: Unfortunately, without the extra image and sound files, there's no way to test your program. Thus, all we have to go on is your comments here. Can you explain just what isn't working? What is going wrong? I gather you aren't used to these forums; it can take a while … | |
Re: Let's go back to the original problem spec: what [i]exactly[/i] does the assignment say? Does it have to actually open the program Notepad.exe, or do you simply need to display the results in some kind of textbox? Does the data have to be editable? Does it have to be saved … | |
Re: As you can see, LogicallyInsane, the question you're asking isn't very clear as the answers were focused on the example rather than the actual meaning behind it. What is it you are trying to accomplish? Just how are you trying to 'combine' if: statements? Do you mean, how do you … | |
Re: The easiest solution would be to use a list, and simply append each new object to the list in a loop. To follow your book list example, here's a sample program that does what you seem to be looking for: [code]class Book (object): def __init__(self, title): self.title = title titles … | |
Re: You will want to start by reviewing the [url=http://www.bittorrent.org/beps/bep_0003.html]Bittorrent Protocol Specification[/url], if you haven't done so already. You may want to see [url=http://wiki.theory.org/BitTorrentSpecification]this[/url] as well, as it gives a somewhat easier to follow version of the protocol spec. The [url=http://en.wikipedia.org/wiki/BitTorrent_%28protocol%29]Wikipedia article about the protocol[/url] may also prove useful. The first … | |
Re: Is it safe to assume that there is more to this code somewhere? I ask this because the index values never get changed in the code as given, which would result in an endless loop. As for initializing the arrays to zero, the best approach is the one given by … | |
Re: The best place to look for operating system development information would be [url=http://www.osdev.org]The OS-Dev Wiki and Forum[/url]. They have a wealth of knowledge and several experienced systems programmers on the message boards. I will warn you, however, that they expect you to come well-prepared when asking questions on the fora, … | |
Re: Actually, the align type doesn't impact the maximum size of the segment. In real mode, a segment has a maximum size of 64K, regardless of any other factors, and segments are always aligned on 16-byte pages. In other memory modes, things get more complex, and you can have segments of … | |
Re: If OS development is what you have in mind, you might want to look into the [url=http://www.osdev.org/]OS-Dev Wiki[/url] and forums. I'll warn you, though, they are not very tolerant of those who come into their message board unprepared, or who don't follow the forum rules; make sure that you've exhausted … | |
Re: You have to keep in mind that the goal is to get the month, not the amount. To get that, you need to actually iterate through the months where the rainfall occurred, and save the one which had the highest rainfall. That having been said, this version will return both … | |
Re: First off, you never set [icode]retailPrice[/icode], which presumably should be getting it from [icode]myRetail.price[/icode], or else from a method of some sort. Also, the price for [icode]myRetailItem[/icode] isn't being set in the [icode]Transaction[/icode] class' [icode]main()[/icode] function. Furthermore, the [icode]myRetailItem[/icode] object in Transaction is not the same as the one in … | |
Re: we can start by 'correcting' the indentation, courtesy of [url=http://astyle.sourceforge.net/]astyle[/url]: [code]#include<stdio.h> int main() { int i, j; int n,M[10][10],min=3267; /* read in the values of the matrix */ printf("\nEnter the order of square matrix:"); scanf("%d",&n); for(i=1; i<=n; i++) { printf("\nEnter the elements of the row %d:",i); for(j=1; j<=n; j++) { … | |
Re: The easiest solution is to use min(), which finds the object in a list that sorts lowest. You can then use remove() on the original list and call selsort() on the remaining part of the original, which can be added to the sorted list with the extend() method. | |
Re: Can you tell us about the format of the text file your reading - that is to say, in what order do you expect things in? For example, does it have the name of the employee followed by the hourly wage followed by the hours worked? Or is it in … | |
Re: I'll look over the code and see if I can find anything that stands out but there is one thing I can say: you would be wise to use [icode]fgets(str1, 10, stdin)[/icode] with instead of [icode]gets(str1)[/icode], as gets() can all too easily have a buffer overrun and crash the program. … | |
Re: It depends on how you're handling the inserts, and whether you're using the list as a queues or not. If you are inserting to the end of the list, then having a pointer to the last element is a practical way of speeding up insertions. However, how you insert may … | |
Re: First off, what hardware and/or emulator is this for (PS2, SPIM, MARS, MIPSsym, etc.)? Keep in mind that, if this is for actual MIPS hardware and not SPIM, then you have to take the branch and load delay slots into account (unless the assembler is doing that for you automatically, … | |
Re: Ordinarily, I would simply direct you towards Google, but after quickly checking the results myself I find that there aren't many such resources to be found. [url=http://books.google.com/books?id=O3pHJF13Y8sC&pg=PA166&lpg=PA166&dq=pep8+assembly+language&source=bl&ots=-TtnfeMzHe&sig=c_VEFzmfvHtjYWjs2obM1mxPdZ8&hl=en&ei=w6O5TKi1C8T7lwfPjOnTDQ&sa=X&oi=book_result&ct=result&resnum=3&ved=0CBgQ6AEwAjgK#v=onepage&q&f=false]This online textbook[/url] is probably the best resource I was able to find. | |
Re: Basically, the function returns the difference between the lower number and the higher number, if and only if the lower number is the first number. The 2 is to account for the fact that both the lower number is being incremented and the higher decremented when they are passed to … | |
Re: I'll do the OP a favor here and repost his code (retrieved via Reply) with appropriate formatting: [code=Python]import urllib import zipfile import re totaal = 0 commentaar = [] lus = True image = urllib.URLopener() image.retrieve("http://www.pythonchallenge.com/pc/def/channel.zip","channel.zip" ) bestand = "readme.txt" zf = zipfile.ZipFile('channel.zip') while lus == True : for filename … | |
Re: [i]Oh dear. I recently used this over at DevShed, and now I fear I need to use here, too. Pity.[/i] First off, we don't do other people's homework for them. Second, we don't do other people's homework for them. And third, we don't do other people's homework for them. Sensing … | |
Re: While there may not be much to it yet, it is a start. I would, however, recommend being more careful with indentation. I would also suggest changing the long series of if()s to a single switch() statement, as that would probably be clearer: [code]#include <stdio.h> #include <string.h> int main() { … | |
Re: Certainly. Nested if:s are a common thing, though you generally don't want the nesting to go too deep for the sake of readability. | |
Re: While Dev-C++ and Code::Blocks are indeed good IDEs, that's all they are - development environments. They both use the [url=http://www.mingw.org/]MinGW[/url] version of GCC for their default compiler, and that may be the best choice to use with Eclipse,too. OTOH, if you get Visual C++ Express, which like MinGW is free, … | |
Re: OK, here's the thing: Python, by itself, is not a language designed specifically for web-page design, the way the (for example) PHP or Javascript are. It can be used for this purpose, but you need to import some particular tools for it, namely the cgi module. What CGI stands for … | |
Re: Before we go further, can you tell us which assembler you're working in? There are significant differences in how different assemblers handles structures. Also, if you're working in linked lists, we'll also need to know the operating system, as you'll need to use the system calls for memory allocation and … | |
Re: As a piece of advice, you could probably make the program a lot more readable if you broke main() down into several separate functions. Also, you could use switch() rather than the long series of if/else if/else statements when testing (for example) nCheckOut - though in that particular case you … | |
Re: If I understand what I've read [url=http://mail.python.org/pipermail/python-bugs-list/2003-September/020405.html]here[/url] and [url=http://forums.devshed.com/python-programming-11/a-few-socket-questions-75012.html]here[/url] correctly, what is happening is that the timeout value isn't being set, which means that the socket is being treated as non-blocking (that is, it should not wait for the other end of the socket); however, certain socket operations apparently only … | |
Re: If you have interest in mathematical computing, you could try [url=http://projecteuler.net/]Project Euler[/url]. Also, you could join one of the many projects on [url=http://www.sourceforge.net]SourceForge[/url] or [url=http://savannah.nongnu.org/]Savannah[/url], or simply download the source code from a few of them to read it. Finally, you could try learning about different languages, as this can … | |
Re: You could also implement a discriminant union and make a queue of those; this would let you use doubles for the numbers. [code]enum QueueElementType {NUMBER, OPERATOR}; struct QueueElement { enum QueueElementType type; union { double number; char operator; } element; struct QueueElement *next; };[/code] | |
Re: I would actually start by implementing the [icode]GradeRecord[/icode] class, if it hasn't been provided for you already. That's really more the key to this sort of problem than the [icode]main()[/icode] function will be. Also, I am assuming that [icode]<isostream.h>[/icode] is supposed to be [icode]<iostream.h>[/icode], in which case I can only … | |
Re: First, you would create the Fraction object using [icode]new Fraction(x, y);[/icode], with whatever values you need there instead of x and y. So, if you were multiplying 1/2 by 2/3, you would write: [code]Fraction first = new Fraction(1, 2); Fraction second = new Fraction(2, 3); Fraction third; third = first.multiply(second);[/code] … | |
Re: [url=http://c2.com/ppr/]The Portland Pattern Repository[/url] (aka Ward's Wiki) was originally founded for users to identify and name patterns; while it has drifted quite a ways from this original purpose, it still has a very comprehensive directory of the known patterns. | |
Re: That last part is valid, if confusing. There is a little-used comma operator in C and C++ that acts more or less the same as a semi-colon; it is mostly used to allow multiple statements in the initialization and increment sections of for() loops, but it works elsewhere as well. … | |
Re: I would recommend not using the lowercase 'l' as a variable name; it's too easily confused with the numeral '1'. Also, you don't need the extra variable here; the two loop indices are enough information. if you rename 'l' as 'j' and reverse the test in the if statement, it … | |
Re: As a one-time service to the OP, here's the code (extracted by quoting the post) with the original indentation: [code=Python]def egcd(a,b): u, u1 = 1, 0 v, v1 = 0, 1 while b: q = a // b u, u1 = u1, u - q * u1 v, v1 = … | |
Re: The MOVSB instruction shouldn't alter the source string, no. However, it does increment both the (E)SI and (E)DI registers so that they point to the next element of the strings. Are you certain that you loaded the two registers correctly? What if anything does it do to the destination string? … | |
Re: Hold on here. Getting the mean (or average) is a fairly simple thing in and of itself: [code]import math def mean(*alist): return sum(alist) / float(len(alist))[/code] What you're doing doesn't seem to be aimed at just getting the mean of a list of values, however. What is [icode]item[/icode] for, and just … | |
Re: What have you tried so far? I would recommend writing out an algorithm for the conversion first, then try to work out what needs to be done to implement it in assembly language. | |
Re: For a single for() loop, the x86 instruction set has a special LOOP instruction. [code]mov ecx, 5 start_loop: ; the code here would be executed 5 times loop start_loop[/code] (Example taken from [url=http://en.wikibooks.org/wiki/X86_Assembly/Control_Flow]here[/url].) However, that has a number of serious drawbacks, with the most serious one being that it really … | |
Re: Has your coursework covered writing your own functions, yet? Given the particular restrictions, and the usual solutions to them both, I would expect that this is meant as an exercise in function writing - more specifically, in writing [i]recursive[/i] functions, as both exponentiation and converting a decimal string to an … | |
Re: I'm afraid you've misunderstood what Momerath was saying about using braces around if()/else statements, with results that are effectively meaningless. Rather than this:[code] {if} (lastYearProduction < 0) Console.WriteLine("Invalid"); { else } Console.WriteLine("Enter This Year's Production"); thisYearProduction = Convert.ToDouble(Console.ReadLine());[/code] Momerath meant for you to do something more like this: [code] if … | |
Re: I think the main problem is that you're trying to apply the string operator .replace() on a dictionary. You need to get the individual keys and do a replace for each of them: [code]def wordReplace (wordText): """ Takes a list of strings and prints out the equivalent text in Pirate-speak.""" … | |
Re: Well, first off, [icode]t.go = False[/icode] isn't going to have the effect you're trying to achieve, as you can see if you run [icode]print(t.isAlive())[/icode] after that line - the answer you'll get is True, whereas if you used [icode]t.join()[/icode] (which causes the main thread to wait until t is completed), … | |
Re: Probably the best place to look for information of this type is the [url=http://wiki.osdev.org/Main_Page]OSDev Wiki[/url] and its corresponding forums. However, I will add that even there, most of the information on writing your own bootloader assumes floppy disks, as those were for a long time the easiest medium to come … | |
Re: Can you tell us exactly how it is misbehaving? On a side note: while not directly connected to the problem at hand, I would recommend setting up equates for the DOS calls, as that will make the code a lot easier to read and correct: [code=Assembly] DOSCALL EQU 21h PRINTSTRING … | |
Re: I tested this on my system (Ubuntu Linux 10.4, compiled with GCC 4.4.3) and it does print the child process' PID, but the Fibonacci print does fail even with the correct prototype and argument types. The problem appears to be in either computeFibonacci() or printFibonacci(). BTW, with the Unix C … |
The End.