- Strength to Increase Rep
- +12
- Strength to Decrease Rep
- -3
- Upvotes Received
- 230
- Posts with Upvotes
- 198
- Upvoting Members
- 109
- Downvotes Received
- 6
- Posts with Downvotes
- 6
- Downvoting Members
- 6
Programmer since 1991 - extensive C++ experience (at Rogue Wave Software) - Java experience (Various web service companies) - recent expertise: Python (Mozilla: Socorro project) - MySql and Postgresql at the 'informed non-expert' level I also do shell…
- Interests
- Reading, contradance, music: Jazz, classical, instrumental folk, ethnic
- PC Specs
- I've always used some flavor of Unix/Linux. Currently OS/X.
Re: Just a small warning that you have to be careful not to create an ever increasing herd of spiders when you start spawning them in multiple threads or processes. As with robots.txt, you have responsibilities to the community (and a contract with your ISP) | |
Re: [QUOTE=britanicus;1545317]Here is your problem: [CODE] choice = input("ENTER CHOICE: ") [/CODE] Changing 'input' to 'raw_input' will solve your problem. You must probably try this to know the difference: [CODE] >>> input( "Enter something: " ) 5 5 >>> input( "Enter something else: " ) britanicus Traceback (most recent call last): … | |
I'm writing a utility that will likely be called by a script that uses `argparse`, but should be useable by any script. The engine object constructor needs a dozen or so parameters to tune its behavior. The question is: What is the best way to allow the caller to send … | |
Re: My very first thought is that what you want to do is extremely annoying: You're grabbing the keystream away from the user right while the user is still typing. That's why word processors typically don't do that; they simply mark the (probable) error and let the user do the correction … | |
Re: Another way: Break from the loop immediately when [iCODE]choice == '5'[/iCODE] Another way: [icode]eval("sys.exit(0)")[/icode] for choice 5 I would prefer, though: add[CODE]def func_5(): print 'quitting' [/CODE] and do the obvious thing on line 16 | |
Re: Most of the code I've written doesn't count as a 'program' because I've mostly worked down among the gears and grease, making libraries or writing other utility code. (or testing...). Some high(low)lights:[list] [*]Commercial grade: hash table, B-tree, and a rewrite of a B-tree-on-disk (simple database). Fun, useful and hard because … | |
Re: The first step in solving that problem is to know what the problem is. I know of at least three different problems that mention a monkey and a banana. One involves a hanging banana, a monkey and a tool of some kind. One involves a banana behind a barrier and … | |
Re: The function named "raw_input" in Python 2.x is named "input" in Python 3.x . Since you did not specify what version of Python you use (until your last post), people were naturally confused. More so since many many more Python 2.x users than 3.x. | |
Re: From personal preference (not raw utility), I find PHP to be ugly, arcane and difficult. It is, as noted, nearly ubiquitous, free, powerful and has lots of available packages. [B]mysql_real_escape_string()[/B] is probably not the best way to deal with incoming data, though it works. Better, in my opinion, to use … | |
| |
Re: Consider using [URL="http://linux.die.net/man/3/gettimeofday"]gettimeofday()[/URL] which keeps track of seconds and microseconds since the epoch. To compare them, subtract the two fields individually, then multiply one (or divide the other) and add the differences; then convert as needed. | |
Re: Hmm. First check: Is script1.py a pure text file? If not, there's the problem. Otherwise: Windows or unix-like system? [LIST] [*]If unix-like try chanting [icode]python [I]full/path/to/script[/I][/icode] where that full path might be [icode]./script1.py[/icode] [*]If Windows, try the same sort of thing with the slashes tilted the other way [/LIST] If … | |
Re: If you need to write your own instead of using strftime/strptime, the right answer is probably [URL="http://docs.python.org/library/re.html"]regular expressions[/URL] Regular expression syntax is tricky if you don't already know it (and sometimes, if you do). [CODE] import re timeS = r'(?P<hour>[01]?\d):(?P<minute>[0-5]\d) *((?P<am>[Aa]\.?[Mm].?)|(?P<pm>[Pp]\.?[Mm]\.?)) timeRE = re.compile(timeS) # ... get somestring "some how" … | |
Re: I prefer to send the quit condition as a second argument to the list entry function. That way, if you need 'q' as a valid list member, you can use something else to stop the loop (also works better for folks whose language does not use a 'q' word to … | |
| Re: The one that will best solve your [B]current[/B] (or maybe your [B]next[/B]) problem. As everybody above points out (more or less directly): They all suck sometimes, and they are all Turing Complete, so whatever can be computed, you can describe the program in any of them. |
Re: Start emacs. Type M-x doctor (escape, x, space, "doctor"). You want something like that. Now go look at the lisp code and do it in python. [QUOTE]I am the psychotherapist. Please, describe your problems. Each time you are finished talking, type RET twice. >> I am trying to write an … | |
Re: Actually, I think mappersas should do the work. Suggest: Look at the [URL="http://docs.python.org/library/numeric.html"]numeric and math package for python[/URL]. With that plus the javascript code that I found with a quick google search: [url]http://www.movable-type.co.uk/scripts/latlong.html#rhumb[/url] , you should be able to get the result very easily. | |
Re: For a (ba)sh script I'd look at (g)awk, which allows you to write little functions based on a regex match. You can set (global) variables within the functions, and you can check their values which gives you something resembling a state machine. | |
Re: Pick a programming language. One language. Python is a good choice, but there are many other good choices. Then do some tutorials in that language. When you get stuck, ask (here) for help with what you ran up against. Be sure to show what work you have done. | |
Re: http://en.wikipedia.org/wiki/Benchmark_%28computing%29#Open_source_benchmarks (less than 30 seconds to use Google, decide on Wikipedia, find the Open Source section. Another minute or so to write this reply) | |
Re: Please use the (CODE) button Please tell us specifically what "won't parse the options" means. Do you get options that are incorrect? Does the script run, but no options are seen? What? | |
Re: Did you [thread=78060]Read This Before Posting[/thread]? | |
Re: They all use the Sieve of Eratosthenes one way or another. Here's one for future consideration that uses the [icode]yield[/icode] keyword in a generator that always yields the next prime. On my mac, it found 10,000 primes in about 5 seconds, but took about 85 seconds to find 20,000. It … | |
Re: Think about the flow of logic: Why are you asking the user for a new pair of words on every line? Shouldn't you do that at the top, then just use them in the loop? Here's a function that (almost) returns the line that is manipulated, but if there are … | |
Re: I see no need to make the deep copy. Pick an attr, save its value, try to change it, then if it changed, put back the original. But I'm with lrh9: A function that does two different things is an odd duck: The code that calls it cannot depend on … | |
Re: There is one further consideration: Both fields of study are difficult and time consuming: Unless you are brilliant or/and have much better study habits than most, you will need longer to finish such a double major than most students. Where I attended school, both degrees were in the Engineering department; … | |
Re: This is not the most efficient or tight code, but it works. In particular, the function `populate(...)` could be shorter. In a real world situation `populate()` should raise a useful error if the files aren't found or aren't as expected (many more lines of code) I have also deliberately made … | |
Re: Agile is a way of thinking about requirements, then creating what is needed. Agile practice doesn't even need to be about coding a program, it can be used for any requirements about any product, though programming is the place it is most used. There is no part of Agile development … | |
Re: You can't remember why you came into this room, you can't remember what you were doing before you came in, and you are pretty sure this has happened at least once already today. Or maybe yesterday... | |
Re: You can use an [NDFA (NFA)](http://en.wikipedia.org/wiki/Nondeterministic_finite_automaton) where each transition character in your short string triggers a transition in the NFA, if possible. The google knows about how you might want to start doing that. |