761 Posted Topics
Re: I have not looked at this at all, beyond a quick 20 second scan of what they claim to offer, but it might be worth exploring: [url]http://www.python-excel.org/[/url] | |
Re: Arbitrary precision arithmetic is not easy, and even when well written, not fast. Are you constrained to use C++? Then I suggest you search [URL="http://lmgtfy.com/?q=Arbitrary+precision+in+C%2B%2B"]like this[/URL] otherwise, use a more appropriate language/tool | |
Re: Probably not the best thing to do, though it will apparently work. Your second question indicates that you have a clue. Class attributes belong to the class itself, whereas instance attributes belong to an instance (of the class). So your lists are in the class: There is only one class … | |
Re: You need to think about [URL="http://www.saltycrane.com/blog/2008/01/python-variable-scope-notes/"]the scope of variables[/URL]. As a general rule, you don't want global [B][I]variables[/I][/B] (though global [B][I]constants[/I][/B] are much more acceptable) since the presence of global variables makes your program harder to understand ("where in the heck did [B][I]that[/I][/B] variable change value?")? As a result, most … | |
Re: Hmm. [list] [*][B]unjumble[/B] takes a string of characters and finds all the words (or sets of words) that use up all the letters. You need to read in the system dictionary to do it [*][B]signature[/B] takes a text and finds statistics about the text, treating it as just an array … | |
Re: If you are willing to walk the structure three times, it is easy to use [icode]find[/icode] to do it. For instance [icode]find $topdir -depth 1 -type l -print[/icode] gets all the links in [icode]$topdir[/icode] | |
Re: bkoper16: Please mark this thread as solved. Only you, the original poster (OP) have that link. Marking threads solved, when they are solved of course, helps keep DaniWeb working smoothly. | |
Re: It is best to ask a simple question (sometimes they escape from simplicity though) and when the question is either answered or does not matter any more, then mark the thread "solved". That is best because it makes it easier for other Daniweb users. Then, when you have a new … | |
Re: Perhaps the problem is integer division when the result is less than 1? Try casting the difference to double and see if it helps. | |
Re: I think the task at the end of the chapter is for you to discover how to use `input()` to accept input from the keyboard, and **then** print "Game Over" and exit. Think of Python as a little robot that does exactly and only what you tell it to do. … | |
Re: Your question is not in clear English, but I think you mean "Is there a way to convert an array to a pointer, or a pointer to an array". An array [B]is[/B] a pointer (to the zero-th element), so there's no way to convert. Just use it as is. Your … | |
Re: I use them as follows: [LIST=1] [*]Discover that I have a need for some programming service [*]Look online for a library(*) that seems to offer the service [*]Look for user commentary comparing some top contenders, or commenting on one or another [*]Read the documentation enough to possibly confirm or actually … | |
Re: $@ is a built in variable that holds [B]all[/B] the command line arguments passed to your script. $1 is just the first command line argument. Here's a useless script that illustrates use of $@[CODE]# Usage: bash thisfile anyfile [anyfile...] for fname in $@; do echo "Will cat $fname" cat $fname … | |
Re: You could use [URL="http://docs.python.org/library/itertools.html?highlight=groupby#itertools.groupby"]itertools.groupby[/URL] which has a nice example right in the docs. Once you have the groups, just calculate the ranking: All the folks in the first group tie for 1st place. All the folks in the second group tie for (count of 1st-place people + 1); All in … | |
Re: Or to be a little more specific: You the OP (original poster) have a link at the bottom of the page that allows you to mark the thread solved. I suggest you first post an entry : "This thread marked solved because our requirements changed, not because I got an … | |
Re: Works for me using Python 3.2 (r32:88452, Feb 20 2011, 11:12:31) You have misspelled Torvalds, however. | |
Re: [QUOTE]Write an abstract file filter class ... Create one subclass of your file filter class that performs encryption, another that transforms a file to all uppercase, and another that creates an unchanged copy of the original file.[/QUOTE] I don't see this (interface/abstract) class anywhere in your code It seems to … | |
Re: Somewhere around line 34, just add a block that listens for K_UNPAUSE. K_UNPAUSE might be K_PAUSE, I suppose, if you want it to toggle in which case just change line 35: [icode]paused = not paused[/icode] | |
Re: Your syntax is just wrong in so many ways. Please visit the [URL="http://docs.python.org/tutorial/index.html"]Python Tutorials[/URL] or read the introduction to your Python book again. | |
Re: [CODE]awk 'NR%3==0' file.txt[/CODE] (or 1 or 2 depending on which actual lines you want) | |
Re: If you are working from the command prompt, change directory to the location of your script and try again. OR stay where you are and invoke python on the full path of the script: [iCODE]python C:\joeflims\pywork\one\script1.py[/iCODE] | |
Re: You are trying to use C syntax in Python. Python loops over a range of integers look like this:[CODE]for i in range(680): print(i)[/CODE] Look [URL="http://docs.python.org/tutorial/controlflow.html"]here[/URL] ... or perhaps you should start at the [URL="http://docs.python.org/tutorial/index.html"]top of the tutorial [/URL] | |
Re: IMHO, you found Python easier because: [list] [*]It is interpreted, which makes the compile/test/edit cycle faster [*]It was a tiny problem, so the execution speed did not matter [*]The OP doesn't know how to make best use of C++: Using the standard containers makes C++ almost as expressive as Python … | |
Re: So show the code. Here's a hint: [CODE]primes = set((2,3,5,7)) factors = [] for p in primes: if 0 == num%p: num /= p factors.append(p) [/CODE] Now re-do this code so as to check even more possible factors, and handle multiples of the same prime. You can do it two … | |
Re: [QUOTE=Ancient Dragon;1531222]line 37: use == operator, not = operator. That is setting those variables to 0.[/QUOTE] This problem is what gave rise to the way I now code equality checks. Rather than[ICODE]if (i == 0)[/ICODE] I put the manifest constant on the left [ICODE]if (0 == i)[/ICODE]. Now, if I … | |
Re: Please take note of the [URL="http://docs.python.org/library/datetime.html"]datetime[/URL] module, particularly [URL="http://docs.python.org/library/datetime.html#datetime.date"]datetime.date[/URL] which can be used to print all kinds of date-related things (method [URL="http://docs.python.org/library/datetime.html#datetime.date.strftime"]strftime[/URL]) By the time you finish reading all that good documentation and get to this line of my post, you should be slapping yourself on the forehead and thinking … | |
Re: Python egg is the closest jar equivalent. Details [URL="http://mrtopf.de/blog/en/a-small-introduction-to-python-eggs/"]here[/URL] (a little out of date, but easy) and (well not exactly details) [URL="http://stackoverflow.com/questions/2026395/how-to-create-python-egg-file"]here[/URL] P.S. I have always considered jar to be the approximate equivalent to 'library' not to 'executable'. Python eggs are also more like a library than an executable (though … | |
Re: Well, you are asking us to make many assumptions; and you aren't clear about where, exactly, you want the 8 to go in your (one dimensional?) array... so we can't help you. And you should show us some code so we have something to help you [B]with[/B]. I'll offer this … | |
Re: You want line 42: [icode]if(*c1 != *c2)[/icode]. The [icode]read[/icode] method does not append trailing nulls, so your current version cannot work; and of course c1 and c2 are pointers, so comparing them directly is useless for your task. You might want to consider using method [icode]get()[/icode] (with no arguments) which … | |
Re: If your professor doesn't have good examples and references, you need to report (him) to the department head as being incompetent to teach the course. And, since (he) must have chosen "good ones" (by (his) standards), you are much better off using those than some you find anywhere else, since … | |
Re: So, for each file, examine this: [ICODE]os.path.splitext(the_file_name)[-1].lower()[/ICODE] | |
Re: Look [URL="http://download.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String,%20int%29"]here[/URL] | |
Re: Post some code using the (CODE) button, and ask for help making it work better. Using better or more careful English. | |
Re: What is this second '~'? [iCODE]"cd ~/~/work/...[/iCODE] If that isn't the problem, then perhaps you can tell us [B][I]how[/I][/B] the last step doesn't work. | |
Re: Use the built-in method int: lhs = int(raw_input("Number: ") rhs = int(raw_input("Another number ") print "%d plus %d is %d"%(lhs, rhs, lhs+rhs If you wish to have people enter a date, then read about datetime module, paying particular attention to the strftime() and strptime() methods. | |
Re: Classes describe objects Objects hold data and do work If you can imagine your program as "He does something, and in order to do it, he asks her to do something, and she needs help from several of her friends..." then each of the 'he', 'she' and 'friend' might be … | |
Re: You never want to del part of a thing in the midst of a loop over the items in the thing: Think about what must be going on when you call del. Instead, one of two options: [list=1] [*]write each line if it passes the test, as you see it … | |
Re: Is your search engine broken? [URL="http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html"]http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html[/URL]:[QUOTE]If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the right column names and types, and it must have indexes on the referenced keys, as stated earlier. If these … | |
Re: Bear in mind that if the user can see the code in the 'master' script, they can alter it. Obfuscation only works if the user is naive. And think about when the cutoff time is set: If it is done as part of the installation, then the user merely reinstalls … | |
Re: Using bash: This worked fine for my baby test. I can't see any need for the case statement. Of course you will need to poke it into shape to do your particular task.[CODE]change() { mv $1 ${1%$2}$3 } for f in $(find $toplocation -iname '*.txt' -print) ; do change $f … | |
Re: There is nothing stopping you from using either multiple dictionaries or a larger dictionary with a variety of keys. For instance, I am now working on a project where I have a dictionary like this[CODE]{ offset: date, #offset is an integer date: filename, #date is datetime.date filename: lines-from-the-file, #filename is … | |
Re: In lines 3 through 11, I see no 'break' statement. You want something like[CODE]if(_isGameOverForXxx(...)) { break; }[/CODE] don't you? | |
Re: I looked at Google using [icode]email hacking[/icode] and found good references (and news) in the top 10. I suggest you do something similar. | |
Re: Something resembling this:[CODE]for srcfile in $(echo *.data) ; do bn=$(basename $srcfile .data) sinkfile={$bn}.txt grep "something about $bn" srcfile >> sinkfile done[/CODE] Assuming bash, but ksh should work also. The [ICODE]$(...)[/ICODE] becomes [ICODE]`...`[/ICODE] in sh (Bourne shell) line 1: echo *.data works only if you are in the correct directory. You … | |
Re: Well, in the first place this is a "rotate" function, not a "shift", but I'll assume you really want "rotate" You are stepping on your data: What happens to the number that was at index in lines 12 and 16? When it is time to shift it, where is the … | |
Re: hint: Think about a two dimensional array of asterisks. There is nothing sacred about traversing such an array in row-major order. | |
Re: Another speedup: You only need to check for factors up to the square root of the target. | |
Re: Start with something very much simpler: A tutorial about how to program in VB. Once you have done that, do some tutorials on how to use a database, which is very very different from Visual Basic. Then, if you are still interested, you will be able to do it (maybe … |
The End.