761 Posted Topics
Re: Either it isn't in your python path (examine sys.path) or it isn't being recognized as a module. Most modules are a file, such as in your case a file named [ICODE]mechanize.py[/ICODE] if you have a directory, then to find files within it, you need a file named [ICODE]__init__.py[/ICODE] (which might … | |
Re: A recursive function calls itself (or calls a function that calls a function that ... calls the original). If you think about a magic square, where would there be a chance to recurse? Since we need to test the main diagonals as well as the rows and columns, we can't … | |
Re: What have you tried? What worked? What didn't? Do you have a specific question? | |
Re: Please use the CODE button to show indents, line numbers, syntax coloring... Hints: * You can get the list of words by simply saying `words = sentence.split()` * You need to think about punctuation, in case user inputs some. For instance, if you got the words from the first sentence … | |
Re: Because Python has 2.x and 3.x versions, it is wise to mention the python version in the module comment or string It would be nice of you to print a summary of the state of the game in the game loop. Such as [ICODE]print("Correct guesses: %s; Wrong guesses: %s"%(correct_guesses, wrong_guesses))[/ICODE] … | |
Re: I get a factor of 1.67 . If you need to explain that 1.2 is the correct factor, then you have to say that something else is important. Maybe I/O on the new machine is faster or the new machine has faster/larger CPU-side cache or ... | |
Re: Not clear to me why you have table CATALOG instead of having that information directly in table VIDEO (unless you are planning to add non-video items? Even so, I think that the VIDEO table is the CATALOG table (and add a "type" column to it so you know if it … | |
Re: I have to dispute your "pretty much done". I spotted a half dozen problems before I looked at your errors. That said: If you actually read the error messages, they give you pretty good clues about what the problem is. Main clue: What line is the parser on when it … | |
Re: I speak no VB, so in general terms: [LIST=1] [*]You open a connection to (some web service) [*]You provide your bona fides to that server [*]You make your request [*]You receive and parse the data [*]You close the connection [*]You massage the new data [*]You display the massaged data [/LIST] … | |
Re: What you want is to put two or more sql statements into a single transaction. How you do that in PHP is not something I know. | |
Re: You really should consider what [B]else[/B] the world needs. Web browsers have been done, and done very well (though they keep getting better, it is incremental). The people who say "start small" are partly correct. Instead, I suggest you start with something that has been making you crazy, that a … | |
Re: It means that the replace function expects a string (or string-like object) as the first parameter, but you passed it an integer. Line 17 should be [icode]board = board.replace(str(comp), "O")[/icode]. Note that the semicolons at lines 7, 12, 17 are not needed, though they are not illegal. | |
Re: The print function by itself adds a newline at the end. I suspect you are doing something like this (though you showed no code, so I am guessing)[CODE]asterisks = '*'*5 print(asterisks+'\n') print(asterisks+'\n')[/CODE]This will work just fine without the explicit newline. Of course if you want an embedded newline, you have … | |
Re: I would be tempted to represent the polynomial as a list of coefficients. The nth item in the list is the coefficient of [icode]x^n[/icode] This requires specific 0 coefficients for all terms. It doesn't work (without jiggering) for negative exponents. A dict also works: Key is exponent, value is coefficient. … | |
Re: I kind of like find for this because if "all" isn't exactly right, it is easy to tune.[CODE]find $basedir -print[/CODE] or if you want a lot of detail: [CODE]find $basedir -ls[/CODE] | |
Re: The problem description is a good start. Now you have to think about how to organize your code. Nothing (much) to do with the language, mostly to do with logic. You will have an [icode]int main()[/icode] just like in C++; and per the instructions, you will need at least four … | |
Re: macros do not honor any kind of scoping. Somewhere in the include files the token 'sec' is being converted to the manifest constant 3600. This is one reason that we have all agreed that macros will always be CAPITALIZED since that much reduces the chance of such conflicts. Better yet, … | |
Re: That has to do with the flow of control (logic) of the program as a whole: Something you did not show us. | |
Re: When upgrading the underlying code / compiler / whatever for your work, the thing of greatest importance is that you know the upgrade worked. For this, you must have an already existing test suite that you trust to tell you when something breaks. The upgrade process then works like this: … | |
Re: You can convert the list to a string with one item per line like this: [CODE]my_list = [ ... ] my_list_as_string = '\n'.join(str(x) for x in my_list)[/CODE] Then you simply write that string to the file. Be careful about adding a newline after the last element. You can use a … | |
Re: The general opinion is that MySQL is accessible, easy to use. Postgresql is robust, more technical, harder to get started using. I've used both without any real trouble (but the Postgres one was set up and administered by someone else). MS SqlServer Express may be good for you if you … | |
Re: It is always very good to have a backup in case something goes wrong, so[list=1] [*]make a new directory beside current one: [icode]mkdir ../something-or-other[/icode] [*]do the work with target ../something-or-other/$filename [*]clean up:[icode]thisdir=$(pwd);cd ..; mv $thisdir $thisdir.back; mv something-or-other $thisdir; cd $thisdir[/icode] [/list] Beware that I did [B]not[/B] test this code, … | |
Re: More or less by definition, shell scripting is done in the language of the shell you use. The most common these days are the Windows "batch" shell, which is very little used, but runs on all Windows machines; and [URL="http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html"]bash[/URL] (Born Again SHell) which is very common on Unix flavored … | |
Re: Your question did not make it into the English language well enough to understand. Also: Please post your code (which should be short, if possible). Be sure to use the CODE button. | |
Re: The main thing is to be clear in your own mind about what you are doing. You are not "converting a decimal number". What you want to do is [B][I]display[/I][/B] a number in octal. This is done by formatting the number. The big hammer is built-in function [icode]format[/icode] which uses … | |
Re: You might want to use a language you already know. If you need to learn a language, then I suggest the [URL="http://python.org/"]Python[/URL] programming language instead of Java. It has about the same expressive power as Java, a similarly powerful set of tools in the standard library, and in my opinion … | |
Re: I have no idea what you mean by your question. How is line 145 now an "output"? It looks like a calculation. There's no print statement, no return statement so nothing is being put "out". What do you man "make it an input"? Input is data that comes into the … | |
Re: Why a text file? If you simply want to preserve information from session to session, there are three ways [LIST=1] [*]What you suggested: Write the data to a text file [*][URL="http://docs.python.org/library/pickle.html"]Pickle[/URL], Python's object serializer module (actually: Use cPickle) [*]Use a database [/LIST] I recommend you use pickle. However if you … | |
Re: [QUOTE=mools3;1598068]please i need response !!![/QUOTE] That isn't [B]our[/B] problem, but yours. If you want a response, you need to make it easier to respond. What is the exact nature of the trouble your code is in? Does it [LIST] [*]have a syntax error? What, exactly? [*]not run? [*]not run as … ![]() | |
Re: [URL="http://lmgtfy.com/?q=XAMPP+mysql+can+not+be+stopped.+Busy"]Let me google that for you[/URL] | |
Re: lose the pause, and print the progress indicator at the bottom of the for loop. If that's too fast, keep a counter and print only on every Nth pass through the loop. You don't get a nice steady progression (assuming that the conversions are not equally lengthy), but you do … | |
Re: In your main() function, call [iCODE]lcs = LCS(m,n); // where did m and n come from?[/iCODE] then print that value. | |
Re: The radius is simple math (Pythagorean theorem): the distance between two points (x0,y0) and (x1,y1) is [ICODE]math.sqrt((x0-x1)**2+(y0-y1)**2)[/ICODE] (If you want to think about distance along a path, such as a road, then you are working on a much larger problem) I presume that the Arcgis data contains the restaurant information, … | |
Re: Actually, the first option (keep track of pennies using a (long) integer) is a better choice almost always. If you use floats representing dollars, you are subject to rounding error even if being very careful. This is because a penny ($0.01 decimal) is in fact an infinite repeating binary fraction, … | |
Re: sh and bash have for loops, conditionals etc, so the process of converting something short like this is to understand it, then rewrite it in (ba)sh. From your linux command line, chant [icode]info bash[/icode] or [icode]man bash[/icode]. From a system that has a "real" sh (as opposed to using a … | |
Re: There are probably 100 or more examples of such code right here at Daniweb. See the search box in the upper right corner of this page? Use it! | |
Re: Start hanging out here and at StackOverflow. Discipline yourself to log in at least three times a day to each. Answer questions (or ask them) every time you visit. Go to Google Code, Source Forge, and other places where you can see professional grade code. Download and figure out how … | |
Re: Django appears to be winning the battle for the minds of programmers with "serious" (== big) development needs. TurboGears looked very interesting when I was researching how to develop a site, but I ended up going with Django. There are a lot of others, including some very small ones. You … | |
Re: any machine that can connect to the web site you intend to scrape is suitable. (donning my lawyer hat): Be sure you are following fair use rules as described at healthgrades.com and any other place you would like to scrape information. Because people are so much slower than machines, many … | |
Re: Please re-read the section in your textbook about references. Yes, the bool& is a reference and yes, it has a pointer in it at the machine code level, but it is always automatically deferenced. | |
Re: Why is this a question in the C++ forum? Do, please [thread=78223]Read This First[/thread] | |
Re: OK, I see the red code (by the way, how did you manage to get code without line numbers? The appropriate thing to do is press the (code) button, then paste your code between the tags... or paste first, highlight it all, then press the button) Based on the red … | |
Re: I'm pretty sure it is already there. What makes you think it isn't? | |
Re: sed would be perfect for this. You could also use cut -c if all the tuple-numbers are one digit, or cut -f twice: Once with -d ',' and once with -d ')' | |
Re: Confused. Want wider, but not taller... but you are calling it the Y axis? Assuming you misspoke, will [URL="http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xlim"]this[/URL] do what you need? (There's a parallel method for the Y axis) | |
Re: Do you need to pay attention to case? Your variable declarations don't all match variables in the pseudo-code (allowance versus Allowance, why "Start" but "STOP", "If" but "ENDIF", "Declare" and not "DECLARE"?) | |
Re: For what its worth, my own way to learn something is a little different than what you propose for yourself: I find a project (small, accessible) that fulfills some need of my own, and just start in doing it. The result is a useful tool if all goes well, but … | |
Re: First, you need to use the **CODE** button to maintain indents when you paste your code (you also get code coloring and line numbers, also good things). With Python particularly indent matters. Here is what I think you meant: #!/usr/bin/env python import csv import random alpha = 'abcdefghijklmnopqrstuvwxyz' e = … | |
Re: OK. I'm assuming that you have MySQL installed and running and you want to access it from Python. Otherwise, you'd be posting in the MySQL forum, right? I just chanted [icode] pip install mysql-python[/icode] from the command line. Maybe I did it all [icode]sudo[/icode]? It has been some time since … | |
Re: Another way: If your function has a loop like this[CODE]def myfunc(*args): something = initial_value while True: # your work here return something[/CODE] Then you can check if the loop has run too long with a call to [URL="http://docs.python.org/library/time.html#time.time"]time.time()[/URL] like this:[CODE]import time def myfunc(*args): start = time.time() something = initial_value while … |
The End.