Re: calculating binomial coefficients using itertools
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), repeat(1, len(l) + 1)) > slices = starmap(slice, indices) > l = [sum(l[s]) for s in slices] > return l[1:] Nice, I like seeing interesting ways to use slice. This will be more efficient, though: def binomial(n): value = 1 for i in range(n+1): yield value value = value * (n-i) // (i+1) -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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 web server runs as a particular user, and only has access to the web content and scripts. And those scripts run as the web server process (at most -- it may be that they run at an even more restricted mode). So NO, they do NOT have access to stuff under /root; for ancient CGI-BIN style, they may be restricted to only the files in the CGI-BIN directory. Thats why i was getting permission denied vene when i had +x when i moved the geo.dat file to /home/nikos/geo.dat then the cgi python script was able to opened it. 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 anything. Are you sure that python scripts run under Apache user or Nobody user in my case and not as user 'nikos' ? Is there some way to test that? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make this faster
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 something like this: > > start = time.time() I have been using time.process_time >> If the timing version, which executes function "Solve" one hundred >> times, runs about 80-100 seconds without a significant variation, then >> taking the mean is mathematically correct. > For longer running code, like this, you might also like this: > http://code.activestate.com/recipes/577896/ Thanks for the pointer. > If the best you can say is it takes "80-100 seconds", that's pretty > significant variation, of the order of 20%. That's not a variation of a SINGLE variant. One variant takes 80 seconds and the other variant to be compared with takes 100 seconds. > > In this case, with times of the order of a second per loop, it may be > reasonable to say "in this specific case, the error is too small to care > about", or "I just don't care about the error, since it will be about the > same for different variations of my solve function". But in that case, > why bother looping 100 times? > > >> I can't take the minimum >> since I don't measure the time a single call takes. > > Then perhaps you should. Many thanks, Helmut -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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 = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )
except Exception as e:
host = repr(e)
Tried it myself and it falsey said that i'am from Europe/Athens (capital
of Greece) while i'am from Europe/Thessaloniki (sub-capital of Greece)
If we can pin-point the uvisitor more accurately plz let me know.
Good morning from Greece,
All my Greece visitors as Dave correctly said have the ISP address which
here in Greece is Europe/Athens, so i have now way to distinct the
cities of the visitors.
Is there any way to pinpoint the visitor's exact location?
--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list
Re: Important features for editors
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 should also > point out that RMS, instead of doing the responsible thing and using speech > recognition software, burns the hands of other human beings by using them > as biological speech recognition units. > > Hope youve seen this http://www.cs.princeton.edu/~arora/RSI.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
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 Scrying. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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 going to achieve without getting a wizard to cast Scrying. No, no registration requirements. 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. -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check for threads being finished?
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 the while loop? If so, how long should I >> sleep? That's probably an unanswerable question, but some guidelines on >> choosing the sleep time will be appreciated. >> > > I think your while loop busy-waits until the threads are completed. > Do this instead: > > for t in threads: t.join()# optionally pass a timeout to join A related stdlib tool that many people don't seem to know is the thread pool in concurrent.futures. It supports both waiting for all threads to finish as well as iterating over results as they come in. It also comes with a parallel map() implementation. http://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor-example http://docs.python.org/3/library/concurrent.futures.html#module-functions New in Py3.2, but there's also a backport AFAIR. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Important features for editors
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 recognition software, burns the hands of other human beings by using them as biological speech recognition units.Now for me, an important feature for editor is the ability to command it, not by keystrokes but by function/method invocation. This is be the first step to reducing the disasters caused by misrecognition events injecting unintentional commands into an editor. For example, bring up a file in VI in close your eyes and type some string like "save file" or "end of line". What kind of damage do you get? With an editor RPC, you can bypass all this damage. You turn off keystroke input at the start of a recognition event and all keyboard queue data is injected as characters. All commands are injected by the API.There's a few other things, I need in a very tiny editor to help a part of my accessibility problem. One of the ways I deal with speech recognition user interfaces by creating tiny domain specific languages to solve a problem. You can say them, they are resilient in the face of misrecognition, edit them and you can replay them. Bunch of wins. The tiny editor needs to use the right Windows edit control to work with NaturallySpeaking, save data so that I never have to think about it. It's always on disk, always safe. If I invoke a file by name, I get exactly one instance. And last, I want the ability to filter the contents of the editor through a bit of Python code so I can do transformations on opening the file or writing the file.Further down the road, instead of the classic syntax highlighting, I need dynamic naming of features so that I can say things like "replace third argument", "modify index" for format local times using pattern.I will admit the last one is a bit of a cheat because that's a subset of the domain specific notation I think that earlier. Not a solved problem :-)So important feature editor change depending on your perspective, or should I say, state of impending disability. We all become disabled with age, just some of us age much faster than the rest of the population-- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
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 possibilities: 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? 2) at some point in the distant past, you told Google where you are, and it has dutifully remembered that. Try using an alternate browser in a new session (Firefox has the ability to create a new profile; Chrome/Chromium should have the ability to start up with a virgin profile; I can't say for Safari or IE) and see if Google suddenly lacks the ability to locate you 3) Google has a better IP-to-location map database than you have. You might have to pay real money for such functionality. Or, you might have to use a different library, as the IP-to-location database that I linked you to earlier has both an "IP to Country" and an "IP to City" database. Note that this is often wrong or grossly inaccurate, as mentioned in other threads (geolocation by IP address often puts me in the nearest major city which is a good 45min drive away, and if I just visit Google maps with a fresh browser, it just shows me the state, TX, which is a ~13hr drive across, if done at 65mph the whole way) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
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 to not answer, but that's the best you're going to achieve without getting a wizard to cast Scrying. No, no registration requirements. 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. At some point, you entered your address, and it's stored in some database in the sky. You have cookies on your machine which correlate to that database. Chances are you did it for google-maps, and google shared it with their search engine and other parts. As far as I know, each such company has a separate database, but perhaps google (for exakmple) has an partner API which facebook uses. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Simple recursive sum function | what's the cause of the weird behaviour?
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) except: result += item return result It's supposed to work like the builtin sum, but on multidimensional lists and also with the optional start parameter accepting something like an empty list and so would also works as a robust list flattener. It's just for kicks, I'm not actually going to use it for anything. 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] >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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?
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 result -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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: > result += item > return result That depends on what is an acceptable result ;) For instance: >>> supersum([2, 3], 1) 5 >>> supersum([[1], ["abc"]], []) [1, 'a', 'b', 'c'] -- http://mail.python.org/mailman/listinfo/python-list
Re: how to calculate reputation
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 take True = +1, False=0 [or] True = +1, False=-1 ?? for adding all. I am missing something here.. and that's clear.. anyone please help me on it? If False is representing a down-vote, like you say, then you have to incorporate that information, in which case False=-1 ==> a user not merely ignored another user, but marked him/her down. You could express the result as 'x out of y users up-voted this' where x = total true and y = x + total_false -- http://mail.python.org/mailman/listinfo/python-list
Editor Ergonomics [was: Important features for editors]
> 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 assertion. I've been using one form or another of Emacs as a programmer/software engineer for over 30 years. While I have had problems with RSI from time-to-time, there have generally been other factors at play other than just use of a text editor. I have learned how to manage it and recognize the warning signs that indicate the onset of an episode. More likely, rms ignored the problem and had bad personal ergomonics: ignorance or lack of understanding of the problem, poor posture, wrists not in a neutral position, lack of breaks, etc. 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 Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Editor Ergonomics [was: Important features for editors]
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 Well, not all involve the mouse. Editors designed to be used over SSH often don't. But yes, editing text files will tend to involve a lot of typing. That's kinda the point of it :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
need data structure to for test results analysis
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) P2 test_name known fail (bug logged but is closed) P3 test_name known fail (bug is open) P4 If I run my script I will get one of these types of failures - PLUS the number of occurrences of each type, sample data as follows:- P1 new fail | occurrence once (obviously) P1 new fail | occurrence once (obviously) P1 new fail | occurrence once (obviously) P1 new fail | occurrence once (obviously) P2 known fail | occurred previously 10 times in earlier executions P2 known fail | occurred previously 15 times in earlier executions P2 known fail | occurred previously 16 times in earlier executions P2 known fail | occurred previously 5 times in earlier executions P3 known fail | occurred previously 6 times in earlier executions P4 known fail | occurred previously 1 times in earlier executions P4 known fail | occurred previously 12 times in earlier executions . . . etc I want to be store this in an appropriate structure so I can then so some analysis :- if (all reported fails are "new fail"): this is priority 1 if (some fails are "new fail" and some are known (P2/P3/P4): this is priority 2 if (no new fail, but all/some reported fails are "P2 known fail") this is priority 3 if ( all/some reported fails are "P3 known fail") this is priority 4 if ( all/some reported fails are "P4 known fail") this is priority 4 I have tried using dictionary/lists but can't get the exact final outcome I want, any help appreciated -- http://mail.python.org/mailman/listinfo/python-list
Re: Editor Ergonomics [was: Important features for editors]
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 other text > editors before it goes any further than your one unsupported > assertion. Not beyond small sample but beyond singleton: http://ergoemacs.org/emacs/emacs_hand_pain_celebrity.html > * a lot of typing, > * use of modifier keys (ctrl, alt, command, etc) > * movement between the mouse and the keyboard My own experience: The second 2 are the worse culprits. And while emacs is bad on the second, its excellent on the third -- to the extend that you 'live inside emacs,' you dont need the mouse. -- http://mail.python.org/mailman/listinfo/python-list
Re: Editor Ergonomics [was: Important features for editors]
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 meme that Emacs is somehow worse for your wrists than other text >> editors before it goes any further than your one unsupported >> assertion. > > Not beyond small sample but beyond singleton: > http://ergoemacs.org/emacs/emacs_hand_pain_celebrity.html Funny that although that list claims a focus on emacs, the fourth person on the list is a vi user. The upshot here is that people who use keyboards a lot often suffer from RSI. You can't just link it to a particular editor on the basis of a few anecdotes. -- http://mail.python.org/mailman/listinfo/python-list
WHAT DRIVES PEOPLE TO CONVERT TO ISLAM?
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 have religious faith in the unseen supreme inimitable power, and then there are others who believe in some humans as Gods, or animals (e.g. monkeys), fire, idols made of stone, and the list goes on. A lot is associated with having a religious “faith”. Part of it has to do with beliefs passed on through generations. People’s identities therefore get tied to it. Many times, these beliefs and associated feelings are not completely demonstrable by reason or any rational arguments. There is nothing right or wrong with this, but that’s just how the nature of religious faith has come to be. Almost everyone thinks they are right in their faith and beliefs. Being with people and groups with similar faith further strengthens people’s faith, and they see it as right, even though logical reasoning and argument sometimes can’t explain it all. That’s simple human psychology. Islam’s arguments based on intellectual reasoning Muslims believe however, that the Islamic religion is different in this context. One may argue that similar to other faiths there are aspects of it which are not completely demonstrable by reason, but on the other hand the Quranic text, which is God’s words addressing humanity at large, uses intellectual reason, critical thinking, and the process of reflection as a means not only to reinforce the faith of the believers, but also to call non-believers to ponder about the authenticity of Islam as the way of life for humanity at large. Although no religious beliefs can be fully based on logic and reasoning, Islam and Quran provide more than enough examples and an opportunity to examine the truth and the soundness of its message through the lens of empirical evidence and knowledge. No one (Muslim or otherwise) would argue that critical thinking and reflection can be a major catalyst for changing ones life. Critical thinking has been used by many to improve their lives simply because a critical thinker asks probing questions about a situation, collects as much information as possible, reflects on the ideas collected and generated in context of the information available, keeps an open and unbiased mind, and carefully scrutinizes assumptions and seeks alternatives. This is the reason, therefore, that new Muslim converts would attribute the use of intelligent reasoning, reflection and critical thinking when explaining their journey to Islam. Such people cut through the hysteria created in the media to view Islam from a critical lens and following the truth thus comes naturally to them as part of this process. How else can one explain the increase in conversions with the increase of anti-Islamic rhetoric? How else can one explain that more non-Muslim preachers have been converting to Islam than ever before? Although, as Muslims, we believe that guidance comes only from Allah, the use of a person’s God-gifted intellectual reasoning has a very powerful role to play in Muslim converts making that destiny changing decision. And once converted, they rarely go back to their old faiths, simply because a faith whose foundations are built on logic and reason is much less likely to be shaken down than one which simply builds upon a set of rites and sacraments. Reasons attributed by new Converts Some of the reasons given why people convert to Islam are the eloquence of the Quran’s language, its overwhelming scientific evidence and proofs, arguments rooted in intellectual reasoning, and the Divine wisdom behind various social issues. The uniqueness and beauty of the Quran’s text has been marveled by the best of Arab linguists and scholars, both Muslim and otherwise, from the days it was revealed until today. The more knowledgeable people are in the language, the more they appreciate the wonders of the textual fluency of the Quran.Revealed more than 1400 years ago, the Quran also has numerous scientific facts that are being validated by science only in this era. Furthermore, it is the only known religious text that challenges mankind to think, reflect and ponder over the creation at large, social issues, God’s existence, and more. The Quran, in many instances, challenges people to reflect and think on their own, rather than heeding the loose talk of those whose criticism is based on baseless foundations.Finally, the Quran provides a solution to numerous social issues, deviation from which has been known to cause societal chaos at all levels. The Quran is a confident assertion of a Supreme Being; the only known religious book that has a confident assertion of a Supreme Being on all issues ranging from the creation of the universe to
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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 specification here. What should supersum do with the list [1]? Should it recurse into it, or append it as a list? It can't do both. For a list flattener, you would need to either use .append for each element you come across, or .extend with each list, with some kind of check to find whether you should recurse or not. Still, it's a fun thing to play with. I like code golfing these sorts of trinketty functions, just for fun :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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, start) > except: > result += item > return result It's probably more robust to do: def supersum(sequence, start=0): for item in sequence: try: result = result + supersum(item, start) except: result = result + item return result as that way you aren't assuming the signature of type(start). -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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: result += supersum(item, start) except: Bare except statements cover up too many sins. I and others *strongly* recommend that you only catch what you *know* you actually want to (see below). result += item return result I recommend that you start with at least one test case, and with an edge case at that. If you cannot bring yourself to do it before writing a draft of the function code, do it immediately after and run. If you do not want to use a framework, use assert. assert supersum([]) == 0 assert supersum([], []) == [] Do the asserts match your intention? The tests amount to a specification by example. Any 'kind' of input that is not tested is not guaranteed to work. Back to the except clause: only add try..except xxx when needed to pass a test. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
pyc++3d, C++ 3D math module
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 Wizard -- Time heals. My blog : http://thediaryofelvishhealer.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Explain your acronyms (RSI?)
"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 Insanity' (his personal form of megalomania)? That makes the phrase is a claim I have read others making. Lets continue and see if that interpretation works. "should indicate that emacs' ergonomics is not right". Aha! Anonymous believes that using his own invention, emacs, is what drove Richard crazy. He would not be the first self invention victim. But Skip mentions 'worse for wrists'. So RSI must be a physical rather than mental condition. Does 'I' instead stand for Inoperability?, Instability?, or what? 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 two standard medical meanings of RSI seem to be Rapid Sequence Intubation and Rapid Sequence Induction. But those are procedures, not chronic syndromes. So I still do not know what the original poster, as quoted by Skip, meant. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Explain your acronyms (RSI?)
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. Whoops, wrong context. How about 'Richard > Stallman Insanity' (his personal form of megalomania)? That makes the phrase > is a claim I have read others making. > > Lets continue and see if that interpretation works. "should indicate that > emacs' ergonomics is not right". Aha! Anonymous believes that using his own > invention, emacs, is what drove Richard crazy. He would not be the first > self invention victim. > > But Skip mentions 'worse for wrists'. So RSI must be a physical rather than > mental condition. Does 'I' instead stand for Inoperability?, Instability?, > or what? > > 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 > two standard medical meanings of RSI seem to be Rapid Sequence Intubation > and Rapid Sequence Induction. But those are procedures, not chronic > syndromes. So I still do not know what the original poster, as quoted by > Skip, meant. > > -- > Terry Jan Reedy RSI is a repetitive stress injury. -- http://mail.python.org/mailman/listinfo/python-list
Re: Explain your acronyms (RSI?)
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 context. How about 'Richard Stallman Insanity' (his personal form of megalomania)? That makes the phrase is a claim I have read others making. Lets continue and see if that interpretation works. "should indicate that emacs' ergonomics is not right". Aha! Anonymous believes that using his own invention, emacs, is what drove Richard crazy. He would not be the first self invention victim. But Skip mentions 'worse for wrists'. So RSI must be a physical rather than mental condition. Does 'I' instead stand for Inoperability?, Instability?, or what? 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 two standard medical meanings of RSI seem to be Rapid Sequence Intubation and Rapid Sequence Induction. But those are procedures, not chronic syndromes. So I still do not know what the original poster, as quoted by Skip, meant. Repetitive strain injury, I assume. Not sure if you're joking but over here the top 7 hits for "RSI" on Google, as well as the three ads that precede them, are repetitive strain injury-related. -- http://mail.python.org/mailman/listinfo/python-list
Re: Explain your acronyms (RSI?)
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 'worse for wrists'. So RSI must be a physical rather than mental condition. Does 'I' instead stand for Inoperability?, Instability?, or what? Let us try Google. Type in RSI and it offers 'RSI medications' as a choice. "RSI wrist" would probably have been a wiser start. Not all medical conditions have medication associated with them. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Explain your acronyms (RSI?)
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 two standard medical meanings of RSI seem to be Rapid >> Sequence Intubation and Rapid Sequence Induction. But those are >> procedures, not chronic syndromes. So I still do not know what the >> original poster, as quoted by Skip, meant. > > Repetitive strain injury, I assume. Not sure if you're joking but over here > the top 7 hits for "RSI" on Google, as well as the three ads that precede > them, are repetitive strain injury-related. Both of you might want to delete your browser cookies, log out of your Google accounts, and then retry. Maybe disabling JavaScript helps. Or enabling the Privacy Mode in your browser. Or try a different browser all together. Or a different search engine. Google has lots of ways to detect who's asking. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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: result += supersum(item, start) except: result += item return result It's probably more robust to do: def supersum(sequence, start=0): for item in sequence: try: result = result + supersum(item, start) except: result = result + item return result I assume you meant to put "result = start" in there at the beginning. as that way you aren't assuming the signature of type(start). 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 would be 10. How about the following? def supersum(sequence, start = 0): result = start for item in reversed(sequence): try: result = supersum(item, result) except: result = item + result return result -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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 anything. Yes, IF YOU RUN IT UNDER "root"... The ownership of the script file doesn't control the privileges it runs under as long as the file itself is read-access to other "users". I though that the ownership of the script file controlled the privileges it runs under. Who controlls the script's privileges then? The process that calls the script file, i.e. Apache? > as the file itself is > read-access to other "users". What do you mean by that? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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 pionpoint my exact location, even postal code. How do they do it? Can you be more specific please about using the aforementioned HTML5 location API ? Never heard of it. Can it be utilizized via a python cgi script? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple recursive sum function | what's the cause of the weird behaviour?
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 would be 10. How about the following? def supersum(sequence, start = 0): result = start for item in reversed(sequence): try: result = supersum(item, result) except: result = item + result return result Sorry, I've no idea what I was thinking with that reversed thing. The following seems better: def supersum(sequence, start = 0): result = start for item in sequence: try: result = supersum(item, result) except: result = result + item return result -- http://mail.python.org/mailman/listinfo/python-list
Re: Explain your acronyms (RSI?)
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 companies with those initials. The two standard medical meanings of RSI seem to be Rapid Sequence Intubation and Rapid Sequence Induction. But those are procedures, not chronic syndromes. So I still do not know what the original poster, as quoted by Skip, meant. Repetitive strain injury, I assume. Not sure if you're joking but over here the top 7 hits for "RSI" on Google, as well as the three ads that precede them, are repetitive strain injury-related. Both of you might want to delete your browser cookies, log out of your Google accounts, and then retry. Maybe disabling JavaScript helps. Or enabling the Privacy Mode in your browser. Or try a different browser all together. Or a different search engine. Google has lots of ways to detect who's asking. The results I mentioned above were in private browsing in FF. I'm in the UK though so that certainly will have made a difference. -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
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-side JavaScript, it runs, well, on the client's browser. Note that the user may be prompted regarding whether they want to permit the website to access location information, so this information may not be available. If the user permits and JS is enabled, the client-side JS code can then make AJAX requests (or stash it in a cookie that gets sent with future requests) to convey the location information to the server where your Python code is running. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
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 calls the script file, i.e. Apache? Yes. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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 interpreter has which in turn will inherit the kind of access the user that is run under upon has? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list
Re: Geo Location extracted from visitors ip address
Στις 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.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"
Longitude: " + position.coords.longitude;
}
'''
Will that do the trick?
but then again i want the city to be stored in the city variable.
Somehow the above javascript code mu return me a value that i will the
store at variable "city".
I don't know how to do that.
--
What is now proved was at first only imagined!
--
http://mail.python.org/mailman/listinfo/python-list
Re: need data structure to for test results analysis
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_name known fail (but no bug logged) P2
> test_name known fail (bug logged but is closed) P3
> test_name known fail (bug is open) P4
>
>
>
>
> If I run my script I will get one of these types of failures - PLUS the
> number of occurrences of each type, sample data as follows:-
> P1 new fail | occurrence once (obviously)
> P1 new fail | occurrence once (obviously)
> P1 new fail | occurrence once (obviously)
> P1 new fail | occurrence once (obviously)
> P2 known fail | occurred previously 10 times in earlier executions
> P2 known fail | occurred previously 15 times in earlier executions
> P2 known fail | occurred previously 16 times in earlier executions
> P2 known fail | occurred previously 5 times in earlier executions
> P3 known fail | occurred previously 6 times in earlier executions
> P4 known fail | occurred previously 1 times in earlier executions
> P4 known fail | occurred previously 12 times in earlier executions
> .
> .
> .
> etc
I'm assuming you can put this into a list like:
failures = [failure1, failure2, failure3, ...]
A failure can be represented by a "namedtuple" or a class or some
other thing. For simplicity, I'll use a class:
class Failure:
def __init__(self, name, type):
self.name, self.type = name, type
def __repr__(self):
return "Failure({}, {})".format(self.name, self.type)
> I want to be store this in an appropriate structure so I can then so some
> analysis :-
> if (all reported fails are "new fail"):
> this is priority 1
> if (some fails are "new fail" and some are known (P2/P3/P4):
> this is priority 2
> if (no new fail, but all/some reported fails are "P2 known fail")
> this is priority 3
> if ( all/some reported fails are "P3 known fail")
> this is priority 4
> if ( all/some reported fails are "P4 known fail")
> this is priority 4
>
> I have tried using dictionary/lists but can't get the exact final outcome I
> want, any help appreciated
You have your list of Failure()s, so you can do:
if all(fail.type == "new fail" for fail in failures):
set_priority_1()
elif any(fail.type == "new fail" for fail in failures):
set_priority_2()
elif any(fail.type == "P2 known fail" for fail in failures):
set_priority_3()
elif any(fail.type == "P3 known fail" for fail in failures):
set_priority_4()
elif any(fail.type == "P4 known fail" for fail in failures):
set_priority_4()
else:
freak_out()
If you want something else, I'm not sure what you're asking.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Editor Ergonomics [was: Important features for editors]
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 ignored the problem and had bad personal ergomonics: > ignorance or lack of understanding of the problem, poor posture, wrists > not in a neutral position, lack of breaks, etc. 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 I am not an ergonomic expert, but I understand that moving from mouse to keyboard actually helps prevent RSI, because it slows down the rate of keystrokes and uses different muscle groups. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Numeric coercions
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, it will silently be converted to a float when I actually want a TypeError. So I want something like this: def promote(x): if isinstance(x, str): raise TypeError return float(x) but I don't like the idea of calling isinstance on every value. Is there a better way to do this? E.g. some operation which is guaranteed to promote any numeric type to float, but not strings? For the record, calling promote() as above is about 7 times slower than calling float in Python 3.3. [1] Or should that be demote? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Numeric coercions
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 is that if a string somehow gets into the original
> numbers, it will silently be converted to a float when I actually want a
> TypeError. So I want something like this:
>
> def promote(x):
> if isinstance(x, str): raise TypeError
> return float(x)
>
> but I don't like the idea of calling isinstance on every value. Is there
> a better way to do this? E.g. some operation which is guaranteed to
> promote any numeric type to float, but not strings?
>
> For the record, calling promote() as above is about 7 times slower than
> calling float in Python 3.3.
>>> from operator import methodcaller
>>> safe_float = methodcaller("__float__")
>>> safe_float(434)
434.0
>>> safe_float(434.4342)
434.4342
>>> safe_float(Decimal("1.23"))
1.23
>>> safe_float("123")
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'str' object has no attribute '__float__'
>>>
--
http://mail.python.org/mailman/listinfo/python-list
Re: Numeric coercions
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 as fast as calling float. That will probably do :-)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Re: Numeric coercions
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
> safe_float = methodcaller("__float__")
>
> Nice!
>
> That's almost as fast as calling float. That will probably do :-)
*Almost* as fast?
%~> \python -m timeit -s "safe_float =
__import__('operator').methodcaller('__float__'); n = 423.213"
"float(n)"
100 loops, best of 3: 0.398 usec per loop
%~> \python -m timeit -s "safe_float =
__import__('operator').methodcaller('__float__'); n = 423.213"
"safe_float(n)"
100 loops, best of 3: 0.361 usec per loop
%~> \python -m timeit -s "safe_float =
__import__('operator').methodcaller('__float__'); n = 423" "float(n)"
100 loops, best of 3: 0.468 usec per loop
%~> \python -m timeit -s "safe_float =
__import__('operator').methodcaller('__float__'); n = 423"
"safe_float(n)"
100 loops, best of 3: 0.436 usec per loop
Actually, it's a fair bit faster (yes, I am purposely not showing you
the results for Decimals).
--
http://mail.python.org/mailman/listinfo/python-list
Re: Numeric coercions
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(x)
>>
>> from operator import methodcaller
>> safe_float = methodcaller("__float__")
>>
>> Nice!
>>
>> That's almost as fast as calling float. That will probably do :-)
>
> *Almost* as fast?
>
*incorrect timings*
>
> Actually, it's a fair bit faster (yes, I am purposely not showing you
> the results for Decimals).
*sigh*, it seems that was just because it's slower to access
__builtins__ than globals(). float() is maybe 2% faster if you fix
that.
--
http://mail.python.org/mailman/listinfo/python-list
