761 Posted Topics

Member Avatar for rssk
Member Avatar for rssk
0
4K
Member Avatar for jubba_us

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 …

Member Avatar for triumphost
0
157
Member Avatar for computerstudent

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) …

Member Avatar for TrustyTony
0
157
Member Avatar for Fortinbra

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 …

Member Avatar for griswolf
0
97
Member Avatar for kanthmca3

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) …

Member Avatar for thekashyap
0
91
Member Avatar for Dongalor

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 …

Member Avatar for griswolf
0
239
Member Avatar for Agent-of-Chaos

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, …

Member Avatar for smantscheff
0
147
Member Avatar for chiefpf

Please use the CODE button to provide indentation, code coloring and line numbers. All worth doing. What is your question?

Member Avatar for jon.kiparsky
0
169
Member Avatar for zensys

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 …

Member Avatar for zensys
0
149
Member Avatar for uopdom

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?" …

Member Avatar for griswolf
0
105
Member Avatar for gauravk_bhanot
Re: 2NF

In simple words: "No". See, for instance [URL="http://databases.about.com/od/administration/l/bldef_2nf.htm"]this[/URL]

Member Avatar for debasisdas
0
121
Member Avatar for ryanoman0

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 …

Member Avatar for WildBamaBoy
0
294
Member Avatar for tuse

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 …

Member Avatar for shibblez
0
2K
Member Avatar for rscubelek

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 …

Member Avatar for Rashakil Fol
0
518
Member Avatar for JaviP

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 = …

Member Avatar for JaviP
0
623
Member Avatar for shahramjaved

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. …

Member Avatar for best_developer
0
474
Member Avatar for tcl76

[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]

Member Avatar for tcl76
0
249
Member Avatar for Ignatius88

Cut and paste the error please. Or do you mean it doesn't work [B][I]as you expected[/I][/B]?

Member Avatar for smantscheff
0
3K
Member Avatar for jaymo'o

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 …

Member Avatar for rxlim
0
149
Member Avatar for threwup

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).

Member Avatar for griswolf
0
118
Member Avatar for tcl76

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 …

Member Avatar for TrustyTony
0
140
Member Avatar for rssk

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 …

Member Avatar for rssk
0
176
Member Avatar for L3gacy

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]

Member Avatar for L3gacy
0
234
Member Avatar for peck3277
Member Avatar for griswolf
0
109
Member Avatar for Geemon

[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 …

Member Avatar for griswolf
0
112
Member Avatar for CompSci_Guy

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] …

Member Avatar for stultuske
0
160
Member Avatar for rajeesh_rsn

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]

Member Avatar for mwasif
0
119
Member Avatar for Shanti C

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 …

Member Avatar for Shanti C
0
235
Member Avatar for Geemon

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'] …

Member Avatar for griswolf
0
209
Member Avatar for brick79

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 …

Member Avatar for JeoSaurus
0
101
Member Avatar for ramesh125

[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 …

Member Avatar for TrustyTony
0
175
Member Avatar for bumsfeld
Member Avatar for dadaqt

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] …

Member Avatar for gooradog
0
204
Member Avatar for kodera

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, …

Member Avatar for Akill10
0
919
Member Avatar for old_kid

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 …

Member Avatar for griswolf
0
3K
Member Avatar for griswolf

I would like to search DaniWeb, but I want to search only in a particular forum. Am I missing something obvious?

Member Avatar for crunchie
0
75
Member Avatar for iamsmooth

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 …

Member Avatar for griswolf
0
171
Member Avatar for mugenoesis

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' …

Member Avatar for mugenoesis
0
131
Member Avatar for pdk123

* 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 …

Member Avatar for griswolf
0
186
Member Avatar for rcmango

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 …

Member Avatar for griswolf
0
167
Member Avatar for MasterMic

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 …

Member Avatar for MasterMic
0
270
Member Avatar for youLostTheGame
Member Avatar for fia tariq
Member Avatar for rebo544

- 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 …

Member Avatar for richieking
0
130
Member Avatar for lisaroy1

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)

Member Avatar for griswolf
-1
180
Member Avatar for Agent Cosmic

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.

Member Avatar for griswolf
0
134
Member Avatar for idrian211

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 …

Member Avatar for griswolf
0
82
Member Avatar for newcoder310

@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' …

Member Avatar for griswolf
0
79
Member Avatar for diagramatic

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 …

Member Avatar for CharlesKramer
0
245
Member Avatar for ram619

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 …

Member Avatar for ram619
0
104

The End.