761 Posted Topics
Re: Does this command work from the Cmd window? Try providing the complete path to snmpwalk? | |
Re: The [B]right[/B] way to handle such things is to convert to an internal representation which will easily handle any of the input values. In this case: inches. Then you do the math on the internal representation, then only as needed, convert back to the external representation using the mod operator … | |
Re: What you want is in three pieces: 1. The built in [function `range()`](http://docs.python.org/library/functions.html#range) which takes three parameters: first, last+1 and step. Use this to create a sequence of indices into your string. I'm not going to do this for you: It is very simple. 2. [List comprehension](http://docs.python.org/howto/functional.html#generator-expressions-and-list-comprehensions) (see note below) … | |
Re: When you have a problem and you think to yourself "I could use XML to solve that", then you have two problems. (The [URL="http://regex.info/blog/2006-09-15/247"]original quote[/URL] is buried in antiquity) But really: What kind of problem even [B][I]begins[/I][/B] to allow you to choose one of SQL or XML? SQL is a … | |
Re: Awk is probably the best tool for this, if you must do it in shell. Awk is a small programming language of its own, so I will leave it to you to learn it well enough to do this job. You might like to start [URL="http://www.ibm.com/developerworks/library/l-awk1.html"]here[/URL] (or: See my signature) … | |
Re: That was kinda fun. There are two things to know: [LIST=1] [*][ICODE]$BASH_SOURCE[/ICODE] is the path to the currently executing script, as it was invoked; regardless of whether the script is executed or sourced. (actually the value is in [ICODE]${BASH_SOURCE[0]}[/ICODE] but the zero'th element of a bash array is available as … | |
Re: When you use the word 'sample' it means something very specific to a statistician. If you do indeed want a proper sample of your data, you must not truncate it "when the space runs out" because there might be, for instance, something that only shows up in the late evening, … | |
Re: Please use the CODE button to provide indentation, code coloring and line numbers. All worth doing. What is your question? | |
Re: If you move blobs into their own table, the database may be able to optimize access to the primary table(s) because the record size is fixed; and for that matter, the blobs table(s) may also work a little better because they can be optimized for that kind of record. If … | |
Re: This is not something I'd have even thought of trying... That's what transactions are for:[CODE](pseudocode) begin transaction insert blah into table_1; if problem inserting bleh into table_2; then rollback; end transaction[/CODE]Another way to think about this is "How do you know which Book_Name to use when creating a new user?" … | |
Re: The canonical simple solutions are variants on each other [list] [*]Write a loop around the body of your code that asks the user to 'q' if they wish to quit, else it will go around again. [*]Just say [icode]raw_input('Press return to quit')[/icode] at the bottom of the script. Assuming you … | |
Re: Along the same lines as Gromit suggests, try this (I lay no claim to the name 'dupit') Here's a baby script:[CODE]output=script_out_file rm -f $output touch $output dupit() { echo "$@" >> $output $@ >> $output } dupit echo "HELLO" dupit ls -lrt dupit echo "GBYE" dupit sleep 2 [/CODE]Invoke the … | |
Re: Certifications are mostly a waste of money and some time. For the most part, shops that demand such certification are pretty unfriendly to programmers and tend toward inflexibility in a variety of ways. Once you [B]have[/B] a job, it may pay to get your certification to help you advance at … | |
Re: Good for you for finding the CODE button. Thanks. However, your posting is still a little short of good: Please provide the actual "many errors" (or really, just the first couple is enough) In addition: May I suggest that you look up operator += rather than using e.g. total = … | |
Re: In MySql a cluster is several servers working together. Unless you are working in that environment, your question is meaningless. I have no direct knowledge of how MySQL clusters work, but a quick look here: [url]http://dev.mysql.com/doc/refman/5.0/en/faqs-mysql-cluster.html[/url] leads me to believe that from the user's perspective you don't have to care. … | |
Re: [B][I]AttributeError: 'str' object has no attribute 'format'[/I][/B] You are using an older version of Python. You can replace line 27 with this: [iCODE]print('\n'.join('ROW%d=%s'%(index+1,''.join(line)) for index,line in enumerate(bits)))[/iCODE] | |
Re: Cut and paste the error please. Or do you mean it doesn't work [B][I]as you expected[/I][/B]? | |
Re: I recommend that you actually go read some tutorial material. Classes are descriptions of "objects" which are the basis for "object oriented programming" They are also: [LIST] [*]A way of keeping together data and the operations that are appropriate for that data ([B][I]objects[/I][/B]) [*]A way of thinking about programming as … | |
Re: search for the token 'sum'. You will see that you have used it as the name of a function and [B]also[/B] as the name of an array (lines 5 and 10). | |
Re: You're working too hard, and you should avoid using an exception for a 'normal' circumstance. The 'Ask for forgiveness, not permission' Pythonic rule of thumb is intended for actually exceptional conditions. The tool you probably want is the built in function [ICODE]enumerate([I]asequence[/I])[/ICODE] The other key is to use a counter … | |
Re: You have at least two problems: [list=1] [*]The types of your list elements are strings. [*]The list type doesn't have operator minus defined on it [/list] To solve the first problem, just make the list items be floats or whatever: Skip the quotes To solve the second problem, you can … | |
Re: You have to test for equality twice: [iCODE]yn == 'y' || yn == 'Y[/iCODE]' etc. You may find that you also only want to test the first character of [ICODE]yn[/ICODE] to be sure your user didn't add an extraneous (or necessary) keystroke or several, such as [ICODE]"yes\n"[/ICODE] | |
Re: [QUOTE=ultimatebuster;1465020]try commenting out the try.. except block. [B][I]Don't use try except unless absolutely necessary, it might hide a bug.[/I][/B] Also.. I've said this a million times.. don't hard code your instructions. It just gets tedious later.[/QUOTE] On the contrary: Using try/except blocks is the [I]Python way[/I] (tm) [B][I]if[/I][/B] you expect … | |
Re: You have now found out the hard way why a good version/source control system is one of the keys to productive programming. Even a mediocre one is better than nothing. Please spend an hour or five reading up on git, mercurial and svn. [URL="http://www.russellbeattie.com/blog/distributed-revision-control-systems-git-vs-mercurial-vs-svn"]Here[/URL]'s a starting place. The Wikipedia [URL="http://en.wikipedia.org/wiki/Revision_control"]article[/URL] … | |
Re: Simplest answer to type: [iCODE]SELECT [I]whatever[/I] FROM [I]wherever[/I] WHERE [I]something[/I] LIKE 'A%' OR [I]something[/I] LIKE 'a%';[/iCODE] If you also care that the output be ordered: [iCODE]... ORDER BY [I]something[/I][/iCODE] | |
Re: SEOCoder has the best answer: Push the data when you have it. If that is not possible (for instance, your local system is not always available to the server), then you need a "pull" system. If the web server table has a unique and growing key (timestamp, id), you can … | |
Re: There's a problem at line 81:[iCODE]message = input(':').lower[/iCODE] returns "[I]<built-in method lower of str object at 0x2ca360>[/I]". You need [iCODE]message = input(':').lower()[/iCODE] (note the empty parens) I would have written:[CODE]def prompt(acts): while True: m = input(':') message = m.lower()[0] if message == "n": acts['north'] break elif message == "e": acts['east'] … | |
Re: You need 'cut' (awk would be somewhat more efficient, but I always have to fiddle around to get an awk script working):[CODE]cat originalfile | grep 'short_message=' | cut -f2 -d '=' | cut -f1 -d ',' > short_message_file[/CODE]If your file has some '=' before the part you need, then the … | |
Re: [QUOTE=jordan0420;1457367]if you use it in a different part of your program you should also make it a global[/QUOTE] There's a whole semi-religious argument about globals. (Java, for instance doesn't allow them at all, sort of, whereas in some early versions of basic, all variables were global). There are basically two … | |
Re: The trick is to to use the rule for distributing negation over a conjunction (OR) or a disjunction (AND): [ICODE]~(AB) = ~A + ~B[/ICODE] and [ICODE]~(A+B) = ~A~B[/ICODE] (I'm using the [icode]~[/icode] for the negation operator, where you use an apostrophe. With that and the rule that [ICODE]~~A == A[/ICODE] … | |
Re: Doesn't work like that. Java has the idea that all variables are local. That means that they aren't visible except in the block where they are declared. Period. Only in that one block (or blocks that are contained in it). So to get a value from one function to another, … | |
Re: Top block of code, line 1: please don't use the built in type [ICODE]list[/ICODE] as a parameter name. Use, maybe [ICODE]jlist[/ICODE] or [ICODE]somelist[/ICODE] Inside the [ICODE]sortj[/ICODE] body, at the top line, do something like: [iCODE]print("\n".join((str(x) for x in jlist[:3])))[/iCODE]Where you need to pick the '3' to be a big enough … | |
I would like to search DaniWeb, but I want to search only in a particular forum. Am I missing something obvious? | |
Re: You start by reading the manual/text. Then you try writing some code. Maybe take a look around the net with Google. Maybe actually use the search facility at Daniweb (look in the top right corner). I got on hit at Daniweb about 30 or so from the top of a … | |
Re: Because you click 'n', the choice is 'n' so the loop continues. Perhaps you should [CODE]do { // the loop } while(! (choice == 'N' || choice == 'n'))[/CODE]Usually, I prompt "Do another? " and end if the lower case of the first character is not the initial for 'yes' … | |
Re: * Please remember to use the **code** button when you post code. It makes it **so** much easier, better for the people who will be willing to help you. As to your question: >i am not sure, how we can access the same database without indicating which key we are … | |
Re: It is a time/space trade off: For a large tree, depth first search is much smaller than breadth first search; but if an early branch holds no answer and is very large (worst case: never stops) then it may run too long. Iteratively deepening [B]with saved state[/B] would be the … | |
Re: Beware that the number of permutations is very very large: factorial(n) for n being the number of items permuted. The number of permutations to handle a triangle with 4 in the top row is 3,628,800 (10 factorial) and for 5 in the top row, its 1,307,674,368,000. You might be better … | |
Re: //shown in error. May be removed at will... | |
Re: - Use the (CODE) button when posting code: It retains indentation, does code coloring and makes line numbers that we can use in our response. Either press it then paste your code between the tags, or paste your code, then highlight it all and press the (CODE) button. - If … | |
Re: The most obvious difference is that SQL is an international standard and the other two are database implementations that more or less implement that standard (actually, both more AND less: they each have non-standard extensions, and each have parts of the SQL standard that they don't (yet) implement) | |
Re: Some databases have enum values ([URL="http://dev.mysql.com/doc/refman/5.0/en/enum.html"]MySql[/URL] and [URL="http://www.postgresql.org/docs/8.3/static/datatype-enum.html"]Postgresql[/URL] both do) that are pretty much what @debasisdas suggested, but hide some of the complexity. | |
Re: I suggest you start by reading [thread=78223]this thread[/thread] Your program will probably have this kind of a layout: [CODE]int main() { loop over the outer (start) values of 3,6,9,12 and 15 loop over the inner (A+something) values print a line of 4 integers }[/CODE] I suggest that in future, you … | |
Re: @masijade explained it in the first answer on your [thread=342627]other thread[/thread]. Let me try it again: For most OSs, you can't guarantee that the contents of a file can be held entirely in memory, so if you want to modify a file, you have to do it in 'reasonable sized' … | |
Re: Somewhat at odds with Ancient Dragon: I think that coding standards are useful prior to peer review, because code that already meets the local/shop spec cuts down on noise during the review process. Do I need a tool to enforce standards? Not so much. Even in a huge shop with … | |
Re: So if you run this on value, say 3, what would the program trace look like? You'd enter fun at line 19 with value 3, fail the test at line 25 (n is 3), fail the test at line 30 (3%2 != 0), enter the 'else' block increment i to … |
The End.