Re: calculating binomial coefficients using itertools

2013-07-06 Thread Ian Kelly
On Fri, Jul 5, 2013 at 4:58 PM, Robert Hunter wrote: > from itertools import count, repeat, izip, starmap > > def binomial(n): > """Calculate list of Nth-order binomial coefficients using itertools.""" > > l = range(2) > for _ in xrange(n): > indices = izip(count(-1), count(1),

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 5:52 πμ, ο/η Dennis Lee Bieber έγραψε: On Sat, 06 Jul 2013 04:10:24 +0300, ? Gr33k declaimed the following: But he cgi scripts when running have full access to the server. No? or they only have the kind of access that their user has also? In any decent system, the

Re: How to make this faster

2013-07-06 Thread Helmut Jarausch
On Sat, 06 Jul 2013 03:05:30 +, Steven D'Aprano wrote: > That doesn't explain how you time it, only that you have a loop executing > 100 times. Are you using time.time, or time.clock? (I trust you're not > measuring times by hand with a stop watch.) > > I expect you're probably doing someth

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 4:41 πμ, ο/η Νίκος Gr33k έγραψε: Yes i know iam only storing the ISP's city instead of visitor's homeland but this is the closest i can get: try: gi = pygeoip.GeoIP('/home/nikos/GeoLiteCity.dat') city = gi.time_zone_by_addr( os.environ['HTTP_CF_CONNECTING_IP'] ) host = soc

Re: Important features for editors

2013-07-06 Thread Rustom Mody
On Sat, Jul 6, 2013 at 12:22 PM, Eric S. Johansson wrote: > ** > On Fri, 05 Jul 2013 23:13:24 -0400, Rustom Mody > wrote: > > Yes... > The fact that rms has crippling RSI should indicate that emacs' ergonomics > is not right. > > > > As someone crippled by Emacs ( actual cause not known), I shou

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Chris Angelico
On Sat, Jul 6, 2013 at 6:01 PM, Νίκος Gr33k wrote: > Is there any way to pinpoint the visitor's exact location? Yes. You ask them to fill in a shipping address. They may still lie, or they may choose to not answer, but that's the best you're going to achieve without getting a wizard to cast Scryi

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 11:30 πμ, ο/η Chris Angelico έγραψε: On Sat, Jul 6, 2013 at 6:01 PM, � Gr33k wrote: Is there any way to pinpoint the visitor's exact location? Yes. You ask them to fill in a shipping address. They may still lie, or they may choose to not answer, but that's the best you're go

Re: How to check for threads being finished?

2013-07-06 Thread Stefan Behnel
Irmen de Jong, 05.07.2013 19:12: > On 5-7-2013 18:59, Steven D'Aprano wrote: >> I then block until the threads are all done: >> >> while any(t.isAlive() for t in threads): >> pass >> >> >> Is that the right way to wait for the threads to be done? Should I stick >> a call to time.sleep() inside

Re: Important features for editors

2013-07-06 Thread Eric S. Johansson
On Fri, 05 Jul 2013 23:13:24 -0400, Rustom Mody wrote:Yes...The fact that rms has crippling RSI should indicate that emacs' ergonomics is not right. As someone crippled by Emacs ( actual cause not known), I should also point out that RMS, instead of doing the responsible thing and using speech re

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Tim Chase
On 2013-07-06 11:41, Νίκος Gr33k wrote: > you know when i go to maps.google.com its always find my exact city > of location and not just say Europe/Athens. > > and twitter and facebook too both of them pinpoint my _exact_ > location. > > How are they able to do it? We need the same way. A couple

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Dave Angel
On 07/06/2013 04:41 AM, Νίκος Gr33k wrote: Στις 6/7/2013 11:30 πμ, ο/η Chris Angelico έγραψε: On Sat, Jul 6, 2013 at 6:01 PM, � Gr33k wrote: Is there any way to pinpoint the visitor's exact location? Yes. You ask them to fill in a shipping address. They may still lie, or they may choose

Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Russel Walker
I know this is simple but I've been starring at it for half an hour and trying all sorts of things in the interpreter but I just can't see where it's wrong. def supersum(sequence, start=0): result = start for item in sequence: try: result += supersum(item, start)

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Russel Walker
Nevermind! Stupid of me to forget that lists or mutable so result and start both point to the same list. -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Russel Walker
Since I've already wasted a thread I might as well... Does this serve as an acceptable solution? def supersum(sequence, start=0): result = type(start)() for item in sequence: try: result += supersum(item, start) except: result += item return res

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Peter Otten
Russel Walker wrote: > Since I've already wasted a thread I might as well... > > Does this serve as an acceptable solution? > > def supersum(sequence, start=0): > result = type(start)() > for item in sequence: > try: > result += supersum(item, start) > except:

Re: how to calculate reputation

2013-07-06 Thread DJC
On 03/07/13 02:05, Mark Janssen wrote: Hi all, this seems to be quite stupid question but I am "confused".. We set the initial value to 0, +1 for up-vote and -1 for down-vote! nice. I have a list of bool values True, False (True for up vote, False for down-vote).. submitted by users. should I t

Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Skip Montanaro
> The fact that rms has crippling RSI should indicate that > emacs' ergonomics is not right. Kind of a small sample size, don't you think? Hopefully we can kill this meme that Emacs is somehow worse for your wrists than other text editors before it goes any further than your one unsupported assert

Re: Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Chris Angelico
On Sun, Jul 7, 2013 at 12:10 AM, Skip Montanaro wrote: > If you stop to > think about it, all text editors probably present similar issues for > their users. They all involve: > > * a lot of typing, > * use of modifier keys (ctrl, alt, command, etc) > * movement between the mouse and the keyboard

need data structure to for test results analysis

2013-07-06 Thread terry433iid
I have a python program that reads test result information from SQL and creates the following data that I want to capture in a data structure so it can be prioritized appropriately :- test_name new fail P1 test_name known fail (but no bug logged)

Re: Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread rusi
On Saturday, July 6, 2013 7:40:39 PM UTC+5:30, Skip Montanaro wrote: > > The fact that rms has crippling RSI should indicate that > > emacs' ergonomics is not right. > > Kind of a small sample size, don't you think? Hopefully we can kill > this meme that Emacs is somehow worse for your wrists than

Re: Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Ian Kelly
On Sat, Jul 6, 2013 at 9:04 AM, rusi wrote: > On Saturday, July 6, 2013 7:40:39 PM UTC+5:30, Skip Montanaro wrote: >> > The fact that rms has crippling RSI should indicate that >> > emacs' ergonomics is not right. >> >> Kind of a small sample size, don't you think? Hopefully we can kill >> this me

WHAT DRIVES PEOPLE TO CONVERT TO ISLAM?

2013-07-06 Thread BV BV
WHAT DRIVES PEOPLE TO CONVERT TO ISLAM? The various aspects of Islam which drives people to convert despite its negative portrayal in the media. The nature of religious faith is quite mysterious. As part of their religious faiths, people believe in a variety of deities. There are people who

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Chris Angelico
On Sat, Jul 6, 2013 at 10:37 PM, Russel Walker wrote: > This works: > - - - - - - x = [[1], [2], [3]] supersum(x) > 6 supersum(x, []) > [1, 2, 3] > > > This does not: > - - - - - - - x = [[[1], [2]], [3]] supersum(x, []) > [1, 2, 1, 2, 3] You have a problem of s

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Joshua Landau
On 6 July 2013 13:59, Russel Walker wrote: > Since I've already wasted a thread I might as well... > > Does this serve as an acceptable solution? > > def supersum(sequence, start=0): > result = type(start)() > for item in sequence: > try: > result += supersum(item, star

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Terry Reedy
On 7/6/2013 8:37 AM, Russel Walker wrote: I know this is simple but I've been starring at it for half an hour and trying all sorts of things in the interpreter but I just can't see where it's wrong. def supersum(sequence, start=0): result = start for item in sequence: try:

pyc++3d, C++ 3D math module

2013-07-06 Thread bubble.rogue
Hi pys, Here is a C++ 3D module based on actors, you can load it in lua, android JNI and of course python. It includes matrix and vector classes with rotate and translate code. See the README and HACKING files for more information. http://sourceforge.net/projects/pycplusplus3d Enjoy, Turtle Wiza

Explain your acronyms (RSI?)

2013-07-06 Thread Terry Reedy
"rms has crippling RSI" (anonymous, as quoted by Skip). I suspect that 'rms' = Richard M Stallman (but why lower case? to insult him?). I 'know' that RSI = Roberts Space Industries, a game company whose Kickstarter project I supported. Whoops, wrong context. How about 'Richard Stallman Insanit

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Benjamin Kaplan
On Sat, Jul 6, 2013 at 12:38 PM, Terry Reedy wrote: > "rms has crippling RSI" (anonymous, as quoted by Skip). > > I suspect that 'rms' = Richard M Stallman (but why lower case? to insult > him?). I 'know' that RSI = Roberts Space Industries, a game company whose > Kickstarter project I supported.

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Rotwang
On 06/07/2013 20:38, Terry Reedy wrote: "rms has crippling RSI" (anonymous, as quoted by Skip). I suspect that 'rms' = Richard M Stallman (but why lower case? to insult him?). I 'know' that RSI = Roberts Space Industries, a game company whose Kickstarter project I supported. Whoops, wrong contex

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Robert Kern
On 2013-07-06 20:38, Terry Reedy wrote: "rms has crippling RSI" (anonymous, as quoted by Skip). I suspect that 'rms' = Richard M Stallman (but why lower case? to insult him?). http://stallman.org/ """ "Richard Stallman" is just my mundane name; you can call me "rms". """ But Skip mentions '

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Stefan Behnel
Rotwang, 06.07.2013 21:51: > On 06/07/2013 20:38, Terry Reedy wrote: >> "rms has crippling RSI" (anonymous, as quoted by Skip). >> [...] >> Let us try Google. Type in RSI and it offers 'RSI medications' as a >> choice. Sound good, as it will eliminate all the companies with those >> initials. The t

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Rotwang
On 06/07/2013 19:43, Joshua Landau wrote: On 6 July 2013 13:59, Russel Walker wrote: Since I've already wasted a thread I might as well... Does this serve as an acceptable solution? def supersum(sequence, start=0): result = type(start)() for item in sequence: try:

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 5:43 μμ, ο/η Dennis Lee Bieber έγραψε: It was some guy form hostgator.com that had told me that a python script has the same level of access to anything on the filesystem as its coressponding user running it, implying that if i run it under user 'root' the python script could access

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 2:20 μμ, ο/η Tim Chase έγραψε: 1) using the aforementioned HTML5 location API, your device may be tattling on where you are. Are you browsing from a smart-phone or other device with a GPS built in? I'm using my lenovo laptop, by maps.gogole.com, fb and twitter have no problem pi

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-06 Thread Rotwang
On 06/07/2013 21:10, Rotwang wrote: [...] It's not quite clear to me what the OP's intentions are in the general case, but calling supersum(item, start) seems odd - for example, is the following desirable? >>> supersum([[1], [2], [3]], 4) 22 I would have thought that the "correct" answer woul

Re: Explain your acronyms (RSI?)

2013-07-06 Thread Rotwang
On 06/07/2013 21:11, Stefan Behnel wrote: Rotwang, 06.07.2013 21:51: On 06/07/2013 20:38, Terry Reedy wrote: "rms has crippling RSI" (anonymous, as quoted by Skip). [...] Let us try Google. Type in RSI and it offers 'RSI medications' as a choice. Sound good, as it will eliminate all the compani

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Tim Chase
On 2013-07-06 23:14, Νίκος Gr33k wrote: Can you be more specific please about using the aforementioned > HTML5 location API ? https://www.google.com/search?q=html5+location+api It's client-side JavaScript. > Never heard of it. Can it be utilizized via a python cgi script? Because it's client-s

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Tim Chase
On 2013-07-06 23:12, Νίκος Gr33k wrote: > I though that the ownership of the script file controlled the > privileges it runs under. Only if the script is SUID. In some environments, scripts can't be run SUID, only binaries. > Who controlls the script's privileges then? > The process that cal

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 11:33 μμ, ο/η Tim Chase έγραψε: Who controlls the script's privileges then? The process that calls the script file, i.e. Apache? Yes. When we run the python interpreter to run a python script like python metrites.py then out script will inherit the kind of access the python inte

Re: Geo Location extracted from visitors ip address

2013-07-06 Thread Νίκος Gr33k
Στις 6/7/2013 11:32 μμ, ο/η Tim Chase έγραψε: Can you be more specific please about using the aforementioned HTML5 location API ? https://www.google.com/search?q=html5+location+api It's client-side JavaScript. so, i must edit my cgi script and do this: print ''' var x=document.getElementB

Re: need data structure to for test results analysis

2013-07-06 Thread Joshua Landau
On 6 July 2013 15:58, wrote: > I have a python program that reads test result information from SQL and > creates the following data that I want to capture in a data structure so it > can be prioritized appropriately :- > > test_name new fail P1 > test_n

Re: Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Steven D'Aprano
On Sat, 06 Jul 2013 09:10:39 -0500, Skip Montanaro wrote: >> The fact that rms has crippling RSI should indicate that emacs' >> ergonomics is not right. > > Kind of a small sample size, don't you think? Yes, but RMS is worth 1000 ordinary programmers!!! *wink* [...] > More likely, rms ignore

Numeric coercions

2013-07-06 Thread Steven D'Aprano
I sometimes find myself needing to promote[1] arbitrary numbers (Decimals, Fractions, ints) to floats. E.g. I might say: numbers = [float(num) for num in numbers] or if you prefer: numbers = map(float, numbers) The problem with this is that if a string somehow gets into the original numbers,

Re: Numeric coercions

2013-07-06 Thread Joshua Landau
On 7 July 2013 04:56, Steven D'Aprano wrote: > I sometimes find myself needing to promote[1] arbitrary numbers > (Decimals, Fractions, ints) to floats. E.g. I might say: > > numbers = [float(num) for num in numbers] > > or if you prefer: > > numbers = map(float, numbers) > > The problem with this

Re: Numeric coercions

2013-07-06 Thread Steven D'Aprano
On Sun, 07 Jul 2013 05:17:01 +0100, Joshua Landau wrote: > On 7 July 2013 04:56, Steven D'Aprano > wrote: ... >> def promote(x): >> if isinstance(x, str): raise TypeError return float(x) from operator import methodcaller safe_float = methodcaller("__float__") Nice! That's almost

Re: Numeric coercions

2013-07-06 Thread Joshua Landau
On 7 July 2013 05:48, Steven D'Aprano wrote: > On Sun, 07 Jul 2013 05:17:01 +0100, Joshua Landau wrote: > >> On 7 July 2013 04:56, Steven D'Aprano >> wrote: > ... >>> def promote(x): >>> if isinstance(x, str): raise TypeError return float(x) > > from operator import methodcaller > saf

Re: Numeric coercions

2013-07-06 Thread Joshua Landau
On 7 July 2013 06:14, Joshua Landau wrote: > On 7 July 2013 05:48, Steven D'Aprano > wrote: >> On Sun, 07 Jul 2013 05:17:01 +0100, Joshua Landau wrote: >> >>> On 7 July 2013 04:56, Steven D'Aprano >>> wrote: >> ... def promote(x): if isinstance(x, str): raise TypeError return float