semi-programmer-ish envs/apps using python

2013-07-05 Thread Rustom Mody
Some systems use python as a glue to make environments which are used by professionals that are not primarily programmers. Some egs: Scientific prog with Scipy+matplotlib Data analysis with pandas Visual arts with processing (Is pyprocessing stable enough?) Linguistics with nltk Is there such a l

Re: Important features for editors

2013-07-05 Thread Joshua Landau
On 6 July 2013 06:19, rusi wrote: > On Saturday, July 6, 2013 10:05:14 AM UTC+5:30, Joshua Landau wrote: >> I never got why Vi doesn't support Ctrl-C by default -- it's not like >> it's a used key-combination and it would have helped me so many times >> when I was younger. > > Dunno what you are r

Re: Illegal suggestions on python list

2013-07-05 Thread Chris Angelico
On Sat, Jul 6, 2013 at 2:40 PM, Joshua Landau wrote: > On 5 July 2013 08:34, Chris Angelico wrote: >> On Fri, Jul 5, 2013 at 5:23 PM, Νίκος Gr33k wrote: >>> Of course we all know that a serial/patch/keygen/crack can be found for this >>> great edit very easily on warez or torrentz sites so it wa

Re: Important features for editors

2013-07-05 Thread rusi
On Saturday, July 6, 2013 10:05:14 AM UTC+5:30, Joshua Landau wrote: > I never got why Vi doesn't support Ctrl-C by default -- it's not like > it's a used key-combination and it would have helped me so many times > when I was younger. Dunno what you are referring to. Out here C-c gets vi out of in

Re: Important features for editors

2013-07-05 Thread Joshua Landau
On 6 July 2013 04:25, Roy Smith wrote: > In article , > Rustom Mody wrote: > >> > I'm a vi user. Once I mastered "hit ESC by reflex when you pause >> > typing an insert" I was never confused above which mode I was in. >> > >> > And now my fingers know vi. > > All the vi you need to know: > > :

Re: Important features for editors

2013-07-05 Thread Roy Smith
In article , Rustom Mody wrote: > > I'm a vi user. Once I mastered "hit ESC by reflex when you pause > > typing an insert" I was never confused above which mode I was in. > > > > And now my fingers know vi. All the vi you need to know: : q ! -- http://mail.python.org/mailman/listinfo/python

Re: Important features for editors

2013-07-05 Thread Rustom Mody
On Sat, Jul 6, 2013 at 4:36 AM, Cameron Simpson wrote: > While I started with vi just slightly before encountering emacs > (mid-to-late 1980s, both), my main trouble with choosing emacs was > the heavy use of control keys. Vi's modal nature means that in > "edit" mode, all the keystrokes are avai

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 18:39:15 +, Helmut Jarausch wrote: > On Fri, 05 Jul 2013 16:50:41 +, Steven D'Aprano wrote: > >> On Fri, 05 Jul 2013 16:07:03 +, Helmut Jarausch wrote: >> >>> The solution above take 0.79 seconds (mean of 100 calls) while the >>> following version take 1.05 second

Re: How to check for threads being finished?

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 19:12:44 +0200, Irmen de Jong wrote: > 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

Re: How to make this faster

2013-07-05 Thread Joshua Landau
On 5 July 2013 17:25, MRAB wrote: > For comparison, here's my solution: Unfortunately, there are some sudokus that require guessing - your algorithm will not solve those. A combination algorithm would be best, AFAIK. - FWIW, this is my interpretation of the original algorithm: from collec

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Νίκος 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_

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Joel Goldstick
On Fri, Jul 5, 2013 at 9:10 PM, Νίκος Gr33k wrote: > Στις 6/7/2013 3:56 πμ, ο/η Joel Goldstick έγραψε: > >> >> Your code is not finding /root/GeoIPCity.dat because your directory has >> this file: GeoLiteCity.dat >> >> FileNotFoundError: [Errno 2] No such file or directory: >> '/root/GeoI

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Νίκος Gr33k
Στις 6/7/2013 3:56 πμ, ο/η Joel Goldstick έγραψε: Your code is not finding /root/GeoIPCity.dat because your directory has this file: GeoLiteCity.dat FileNotFoundError: [Errno 2] No such file or directory: '/root/GeoIPCity.dat' My mistake. Is there a differnce between GeoLiteCity.dat a

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Joel Goldstick
On Fri, Jul 5, 2013 at 8:08 PM, Νίκος Gr33k wrote: > Στις 6/7/2013 2:58 πμ, ο/η Νίκος Gr33k έγραψε: > > Στις 6/7/2013 2:55 πμ, ο/η Νίκος Gr33k έγραψε: >> >>> Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: >>> On 2013-07-05 22:08, Νίκος Gr33k wrote: > Is there a way to extract out of

Re: Coping with cyclic imports

2013-07-05 Thread Cameron Simpson
On 05Jul2013 10:36, Oscar Benjamin wrote: | On 5 July 2013 02:24, Cameron Simpson wrote: | > On 04Jul2013 16:03, Oscar Benjamin wrote: | > | Is there some reason you're responding to a post from 5 years ago? | > | > Is there some reason not to, if no newer solutions are available? | | No, I was

Re: How to check for threads being finished?

2013-07-05 Thread Cameron Simpson
On 05Jul2013 16:59, Steven D'Aprano wrote: | I have a pool of worker threads, created like this: | | threads = [MyThread(*args) for i in range(numthreads)] | for t in threads: | t.start() | | I then block until the threads are all done: | | while any(t.isAlive() for t in threads): | pa

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Νίκος Gr33k
Στις 6/7/2013 2:58 πμ, ο/η Νίκος Gr33k έγραψε: Στις 6/7/2013 2:55 πμ, ο/η Νίκος Gr33k έγραψε: Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: On 2013-07-05 22:08, Νίκος Gr33k wrote: Is there a way to extract out of some environmental variable the Geo location of the user being the city the user

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Νίκος Gr33k
Στις 6/7/2013 2:55 πμ, ο/η Νίκος Gr33k έγραψε: Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: On 2013-07-05 22:08, Νίκος Gr33k wrote: Is there a way to extract out of some environmental variable the Geo location of the user being the city the user visits out website from? Perhaps by utilizing h

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: On 2013-07-05 22:08, Νίκος Gr33k wrote: Is there a way to extract out of some environmental variable the Geo location of the user being the city the user visits out website from? Perhaps by utilizing his originated ip address? Yep. You can get an

Re: Important features for editors

2013-07-05 Thread Cameron Simpson
On 05Jul2013 05:12, rusi wrote: | On Thursday, July 4, 2013 1:37:10 PM UTC+5:30, Göktuğ Kayaalp wrote: | > Programmability comes to my mind, before anything else. I'd suggest | > to find out about designs of Emacs and Vi(m). | | There's one reason I prefer emacs -- and I guess some people | pref

calculating binomial coefficients using itertools

2013-07-05 Thread Robert Hunter
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)

Re: python adds an extra half space when reading from a string or list

2013-07-05 Thread rurpy
On 07/04/2013 02:50 AM, feedthetr...@gmx.de wrote: > Am Mittwoch, 3. Juli 2013 19:01:23 UTC+2 schrieb ru...@yahoo.com: >[...] Any questions? >> Yes. >[...] >> I know the answers to all these questions are obvious >> to everyone else here but I am not sure about them. > > Then I hope, I was

Re: python adds an extra half space when reading from a string or list

2013-07-05 Thread rurpy
On 07/04/2013 06:09 AM, Antoon Pardon wrote: > Op 03-07-13 19:11, ru...@yahoo.com schreef: >> On 07/03/2013 03:21 AM, Antoon Pardon wrote: >>> Op 03-07-13 02:30, ru...@yahoo.com schreef: If your going to point out something negative about someone then do so politely. Ask yourself if you

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Grant Edwards
On 2013-07-05, ?? Gr33k wrote: > Is there a way to extract out of some environmental variable the Geo > location of the user being the city the user visits out website from? No. > Perhaps by utilizing his originated ip address? There is a very poor correlation between IP address and g

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Tim Chase
On 2013-07-05 22:59, Support by Νίκος wrote: > Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: > > On 2013-07-05 22:08, Νίκος Gr33k wrote: > >> Is there a way to extract out of some environmental variable the > >> Geo location of the user being the city the user visits out > >> website from? > >> > >

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Dave Angel
On 07/05/2013 04:44 PM, Tim Roberts wrote: ? Gr33k wrote: Is there a way to extract out of some environmental variable the Geo location of the user being the city the user visits out website from? Perhaps by utilizing his originated ip address? It is possible to look up the geographic r

AMQP listening and user-facing daemon

2013-07-05 Thread Justin Chiu
Hi all, What is the best approach to writing a concurrent daemon that can execute callbacks for different types of events (AMQP messages, parsed output of a subprocess, HTTP requests)? I am considering [twisted][1], the built-in [threading][2] module, and [greenlet][3]. I must admit that I a

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Tim Roberts
? Gr33k wrote: > >Is there a way to extract out of some environmental variable the Geo >location of the user being the city the user visits out website from? > >Perhaps by utilizing his originated ip address? It is possible to look up the geographic region associated with a block of IP addre

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Support by Νίκος
Στις 5/7/2013 10:58 μμ, ο/η Tim Chase έγραψε: On 2013-07-05 22:08, Νίκος Gr33k wrote: Is there a way to extract out of some environmental variable the Geo location of the user being the city the user visits out website from? Perhaps by utilizing his originated ip address? Yep. You can get an

Re: analyzing time

2013-07-05 Thread Gary Herron
On 07/05/2013 12:18 PM, noydb wrote: Hello All, I have a table with a column of type date, with dates and time combined (like '1/6/2013 3:52:69PM'), that spans many months. How would I pull out records that are the first and last entries per day? Also, if I wanted to find time clusters per d

Re: Geo Location extracted from visitors ip address

2013-07-05 Thread Tim Chase
On 2013-07-05 22:08, Νίκος Gr33k wrote: > Is there a way to extract out of some environmental variable the > Geo location of the user being the city the user visits out website > from? > > Perhaps by utilizing his originated ip address? Yep. You can get an 11MB database (17MB uncompressed) http

Re: analyzing time

2013-07-05 Thread Terry Reedy
On 7/5/2013 3:18 PM, noydb wrote: I have a table with a column of type date, with dates and time This is a datetime in Python parlance. combined (like '1/6/2013 3:52:69PM'), that spans many months. How would I pull out records that are the first and last entries per day? Sort on that colu

Re: Convert SOAP response (ArrayOfInt) to Python list

2013-07-05 Thread Burak Arslan
Hi, FYI, There's a soap-specific python.org list: s...@python.org On 07/04/13 20:57, robert.wink...@bioprocess.org wrote: > Thanks to the OSA library, which works for SOAP requests with Python 3.x, I > can now use SOAP services at http://www.chemspider.com. > > The results structure is >

Re: analyzing time

2013-07-05 Thread Skip Montanaro
> I have a table with a column of type date, with dates and time combined (like > '1/6/2013 3:52:69PM'), that spans many months. How would I pull out records > that are the first and last entries per day? You mentioned "table" and "column", which leads me to think you are dealing with data in a

Re: analyzing time

2013-07-05 Thread Neil Cerutti
On 2013-07-05, noydb wrote: > Hello All, > > I have a table with a column of type date, with dates and time > combined (like '1/6/2013 3:52:69PM'), that spans many months. > How would I pull out records that are the first and last > entries per day? > > Also, if I wanted to find time clusters per

analyzing time

2013-07-05 Thread noydb
Hello All, I have a table with a column of type date, with dates and time combined (like '1/6/2013 3:52:69PM'), that spans many months. How would I pull out records that are the first and last entries per day? Also, if I wanted to find time clusters per day (or per week) -- like if an entry i

Geo Location extracted from visitors ip address

2013-07-05 Thread Νίκος Gr33k
Is there a way to extract out of some environmental variable the Geo location of the user being the city the user visits out website from? Perhaps by utilizing his originated ip address? -- What is now proved was at first only imagined! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 17:25:54 +0100, MRAB wrote: > For comparison, here's my solution: Your solution is very fast, indeed. It takes 0.04 seconds (mean of 1000 runs) restoring "grid" in between. But that's a different algorithm which is IMHO more difficult to understand. Many thanks, Helmut > >

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 16:50:41 +, Steven D'Aprano wrote: > On Fri, 05 Jul 2013 16:07:03 +, Helmut Jarausch wrote: > >> The solution above take 0.79 seconds (mean of 100 calls) while the >> following version take 1.05 seconds (mean of 100 calls): > > 1) How are you timing the calls? I've p

Re: How to check for threads being finished?

2013-07-05 Thread Ian Kelly
On Fri, Jul 5, 2013 at 10:59 AM, Steven D'Aprano wrote: > I have a pool of worker threads, created like this: > > threads = [MyThread(*args) for i in range(numthreads)] > for t in threads: > t.start() > > > I then block until the threads are all done: > > while any(t.isAlive() for t in threads

Re: How to check for threads being finished?

2013-07-05 Thread Irmen de Jong
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

Re: How to check for threads being finished?

2013-07-05 Thread Chris Angelico
On Sat, Jul 6, 2013 at 2:59 AM, Steven D'Aprano wrote: > I then block until the threads are all done: > > while any(t.isAlive() for t in threads): > pass > Using the threading module, I assume. Is there any reason you can't simply join() each thread in succession? ChrisA -- http://mail.pyth

How to check for threads being finished?

2013-07-05 Thread Steven D'Aprano
I have a pool of worker threads, created like this: threads = [MyThread(*args) for i in range(numthreads)] for t in threads: t.start() 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? S

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 15:47:45 +, Helmut Jarausch wrote: > > for r, row_lst in enumerate(Grid): > > for c, val in enumerate(row_lst): > > I assume the creation of the temporary lists "row_list" is a bit > expensive. No temporary list is being created. The pre-existing list is just being gr

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 16:07:03 +, Helmut Jarausch wrote: > The solution above take 0.79 seconds (mean of 100 calls) while the > following version take 1.05 seconds (mean of 100 calls): 1) How are you timing the calls? 2) Don't use the mean, that's the wrong statistic when you are measuring so

Re: How to make this faster

2013-07-05 Thread MRAB
On 05/07/2013 16:17, Helmut Jarausch wrote: On Fri, 05 Jul 2013 15:45:25 +0100, Oscar Benjamin wrote: Presumably then you're now down to the innermost loop as a bottle-neck: Possibilities= 0 for d in range(1,10) : if Row_Digits[r,d] or Col_Digits[c,d] or Sqr_Digits[Sq_No,d]

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 14:54:26 +, Helmut Jarausch wrote: > On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: May I suggest > you avoid range and use enumerate(the_array) instead? It might be > faster. > > How does this work? > > Given > > Grid= [[0 for j in range(9)] for i in range(9)]

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 16:38:43 +0100, Oscar Benjamin wrote: > On 5 July 2013 16:17, Helmut Jarausch wrote: >> >> I've tried the following version >> >> def find_good_cell() : >> Best= None >> minPoss= 10 >> for r,c in Grid : >> if Grid[(r,c)] > 0 : continue > > Sorry, I think what I mea

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 16:18:41 +0100, Fábio Santos wrote: > On 5 Jul 2013 15:59, "Helmut Jarausch" wrote: >> >> On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: >> May I suggest you avoid range and use enumerate(the_array) instead? It >> might be faster. >> >> How does this work? >> >> Given

Re: How to make this faster

2013-07-05 Thread Oscar Benjamin
On 5 July 2013 16:17, Helmut Jarausch wrote: > > I've tried the following version > > def find_good_cell() : > Best= None > minPoss= 10 > for r,c in Grid : > if Grid[(r,c)] > 0 : continue Sorry, I think what I meant was that you should have a structure called e.g. Remaining which is th

Re: Default scope of variables

2013-07-05 Thread Neil Cerutti
On 2013-07-05, Chris Angelico wrote: > On Fri, Jul 5, 2013 at 11:24 PM, Neil Cerutti > wrote: >> Python provides deterministic destruction with a different >> feature. > > You mean 'with'? That's not actually destruction, it just does > one of the same jobs that deterministic destruction is used

Re: How to make this faster

2013-07-05 Thread Oscar Benjamin
On 5 July 2013 15:48, Helmut Jarausch wrote: > On Fri, 05 Jul 2013 12:02:21 +, Steven D'Aprano wrote: > >> On Fri, 05 Jul 2013 10:53:35 +, Helmut Jarausch wrote: >> >>> Since I don't do any numerical stuff with the arrays, Numpy doesn't seem >>> to be a good choice. I think this is an argu

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 15:45:25 +0100, Oscar Benjamin wrote: > Presumably then you're now down to the innermost loop as a bottle-neck: > > Possibilities= 0 > for d in range(1,10) : > if Row_Digits[r,d] or Col_Digits[c,d] or Sqr_Digits[Sq_No,d] : > continue > Possibilitie

Re: How to make this faster

2013-07-05 Thread Fábio Santos
On 5 Jul 2013 15:59, "Helmut Jarausch" wrote: > > On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: > May I suggest you avoid range and use enumerate(the_array) instead? It > might be faster. > > How does this work? > > Given > > Grid= [[0 for j in range(9)] for i in range(9)] > > for (r,c,v

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 13:44:57 +0100, Fábio Santos wrote: May I suggest you avoid range and use enumerate(the_array) instead? It might be faster. How does this work? Given Grid= [[0 for j in range(9)] for i in range(9)] for (r,c,val) in (Grid) : Helmut -- http://mail.python.org/mailman/lis

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 12:02:21 +, Steven D'Aprano wrote: > On Fri, 05 Jul 2013 10:53:35 +, Helmut Jarausch wrote: > >> Since I don't do any numerical stuff with the arrays, Numpy doesn't seem >> to be a good choice. I think this is an argument to add real arrays to >> Python. > > Guido's t

Re: How to make this faster

2013-07-05 Thread Oscar Benjamin
On 5 July 2013 15:28, Helmut Jarausch wrote: > On Fri, 05 Jul 2013 14:41:23 +0100, Oscar Benjamin wrote: > >> On 5 July 2013 11:53, Helmut Jarausch wrote: >>> I even tried to use dictionaries instead of Numpy arrays. This version is a >>> bit >>> slower then the lists of lists version (7.2 secon

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 5:11 μμ, ο/η Lele Gaifax έγραψε: Dave Angel writes: You're quoting from my error output, and that's caused because I don't have such an environment variable. But you do. Dave, maybe you already know, but that variable is "injected" by the CGI mechanism, is not coming from the

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 14:41:23 +0100, Oscar Benjamin wrote: > On 5 July 2013 11:53, Helmut Jarausch wrote: >> I even tried to use dictionaries instead of Numpy arrays. This version is a >> bit >> slower then the lists of lists version (7.2 seconds instead of 6 second) but >> still >> much faster

Re: Important features for editors

2013-07-05 Thread Grant Edwards
On 2013-07-04, Ferrous Cranus wrote: > 4/7/2013 9:40 , ??/?? Grant Edwards : >> On 2013-07-04, ?? wrote: >>> >>> If you guys want to use it i can send you a patch for it. I know its >>> illegal thing to say but it will help you use it without buying it. >> >> A ne

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Lele Gaifax
Dave Angel writes: > You're quoting from my error output, and that's caused because I don't > have such an environment variable. But you do. Dave, maybe you already know, but that variable is "injected" by the CGI mechanism, is not coming from the OP shell environment. As Νίκος discovered, whe

Re: Default scope of variables

2013-07-05 Thread Chris Angelico
On Fri, Jul 5, 2013 at 11:24 PM, Neil Cerutti wrote: > Python provides deterministic destruction with a different > feature. You mean 'with'? That's not actually destruction, it just does one of the same jobs that deterministic destruction is used for (RAII). It doesn't, for instance, have any in

Re: How to make this faster

2013-07-05 Thread Oscar Benjamin
On 5 July 2013 11:53, Helmut Jarausch wrote: > I even tried to use dictionaries instead of Numpy arrays. This version is a > bit > slower then the lists of lists version (7.2 seconds instead of 6 second) but > still > much faster than the Numpy array solution. When you switched to dictionaries

Re: Default scope of variables

2013-07-05 Thread Neil Cerutti
On 2013-07-04, Dave Angel wrote: > On 07/04/2013 01:32 AM, Steven D'Aprano wrote: > >> Well, if I ever have more than 63,000,000 variables[1] in a >> function, I'll keep that in mind. >> > >> >> [1] Based on empirical evidence that Python supports names >> with length at least up to

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Dave Angel
On 07/05/2013 06:33 AM, Νίκος Gr33k wrote: Στις 5/7/2013 12:21 μμ, ο/η Dave Angel έγραψε: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.3/os.py", line 669, in __getitem__ value = self._data[self.encodekey(key)] KeyError: b'REMOTE_ADDR Wait! Ar

Re: How to make this faster

2013-07-05 Thread Fábio Santos
On 5 Jul 2013 11:58, "Helmut Jarausch" wrote: > > On Fri, 05 Jul 2013 11:13:33 +0100, Oscar Benjamin wrote: > > > My one comment is that you're not really making the most out of numpy > > arrays. Numpy's ndarrays are efficient when each line of Python code > > is triggering a large number of numer

Fwd: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Αρχικό μήνυμα Θέμα: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Ημερομηνία: Fri, 05 Jul 2013 15:16:45 +0300 Από:Νίκος Gr33k Προς: feedthetr...@gmx.de Στις 5/7/2013 3:06 μμ, ο/η feedthetr...@gmx.de έγραψε: Am

Re: Important features for editors

2013-07-05 Thread rusi
On Thursday, July 4, 2013 1:37:10 PM UTC+5:30, Göktuğ Kayaalp wrote: > Programmability comes to my mind, before anything else. I'd suggest > to find out about designs of Emacs and Vi(m). There's one reason I prefer emacs -- and I guess some people prefer Idle -- the interpreter and editor are ti

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread feedthetroll
Am Freitag, 5. Juli 2013 12:33:05 UTC+2 schrieb Νίκος Gr33k: > ... > Wait! > Are you saying that the ip address is being returned as a byte string > which then i have to decode with something like: > > host = socket.gethostbyaddr( os.environ['REMOTE_HOST'].decode('utf-8') )[0] Wait! I get a deco

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread feedthetroll
Am Freitag, 5. Juli 2013 13:27:25 UTC+2 schrieb Νίκος Gr33k: > Στις 5/7/2013 2:16 μμ, ο/η Lele Gaifax έγραψε: >> UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3 >> first string---^^^ >> second string---^^ > > Hold on please! > From where do these dashes

Re: How to make this faster

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 10:53:35 +, Helmut Jarausch wrote: > Since I don't do any numerical stuff with the arrays, Numpy doesn't seem > to be a good choice. I think this is an argument to add real arrays to > Python. Guido's time machine strikes again: import array By the way, I'm not exactly

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread feedthetroll
Am Freitag, 5. Juli 2013 12:33:05 UTC+2 schrieb Νίκος Gr33k: > ... > Wait! > Are you saying that the ip address is being returned as a byte string > which then i have to decode with something like: > > host = socket.gethostbyaddr( os.environ['REMOTE_HOST'].decode('utf-8') )[0] Wait! I get a deco

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 2:16 μμ, ο/η Lele Gaifax έγραψε: UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3 first string---^^^ second string---^^ Hold on please! From where do these dashes and carets characters come from? Also from where do you see 2 strings? L

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 2:05 μμ, ο/η Νίκος Gr33k έγραψε: Thats what i'm trying to do. If i completely remove the gethostbyaddr fucntion adds function then there is nor problem. The problem is recreating when the script tries to decode a hostname. For some bizarre reason if i exclude my domain from CloudF

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Lele Gaifax
Νίκος Gr33k writes: > Στις 5/7/2013 1:59 μμ, ο/η Lele Gaifax έγραψε: >> Νίκος Gr33k writes: >> >>> UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3 >>> >>> but what string does it try to decode and jeeps failing? >> >> Reasonably it's the second one, as the first clearly seems the tag of >> th

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 1:59 μμ, ο/η Lele Gaifax έγραψε: Νίκος Gr33k writes: Looks now when i print( repr(e)) i get UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3 but what string does it try to decode and jeeps failing? Reasonably it's the second one, as the first clearly seems the tag of the de

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Lele Gaifax
Νίκος Gr33k writes: > Looks now when i print( repr(e)) i get > > UnicodeDecodeError('utf-8', b'\xb6\xe3\xed\xf9\xf3 > > but what string does it try to decode and jeeps failing? Reasonably it's the second one, as the first clearly seems the tag of the decoder that tried to translate it to Unicode

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 11:13:33 +0100, Oscar Benjamin wrote: > My one comment is that you're not really making the most out of numpy > arrays. Numpy's ndarrays are efficient when each line of Python code > is triggering a large number of numerical computations performed over > the array. Because of t

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 1:36 μμ, ο/η Lele Gaifax έγραψε: Νίκος Gr33k writes: Στις 5/7/2013 12:25 μμ, ο/η Νίκος Gr33k έγραψε: try: remadd = os.environ('REMOTE_ADDR') tuple3 = socket.gethostbyaddr(remadd) host = tuple3[0] except Exception as e: host = repr(e) which yields: Typ

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Lele Gaifax
Νίκος Gr33k writes: > Στις 5/7/2013 12:25 μμ, ο/η Νίκος Gr33k έγραψε: >> >> try: >> remadd = os.environ('REMOTE_ADDR') >> tuple3 = socket.gethostbyaddr(remadd) >> host = tuple3[0] >> except Exception as e: >> host = repr(e) > >> which yields: TypeError("'_Environ' object is no

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 12:21 μμ, ο/η Dave Angel έγραψε: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.3/os.py", line 669, in __getitem__ value = self._data[self.encodekey(key)] KeyError: b'REMOTE_ADDR Wait! Are you saying that the ip address is being re

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 1:24 μμ, ο/η Lele Gaifax έγραψε: Νίκος Gr33k writes: You can view the error in the very first line here: http://superhost.gr/?show=log&page=index.html No, visiting that page simply emit the standard Apache error page, without details. which yields: TypeError("'_Environ' obj

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 12:25 μμ, ο/η Νίκος Gr33k έγραψε: try: remadd = os.environ('REMOTE_ADDR') tuple3 = socket.gethostbyaddr(remadd) host = tuple3[0] except Exception as e: host = repr(e) which yields: TypeError("'_Environ' object is not callable",) Any thoufgs as to why os.env

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Lele Gaifax
Νίκος Gr33k writes: > You can view the error in the very first line here: > > http://superhost.gr/?show=log&page=index.html No, visiting that page simply emit the standard Apache error page, without details. > > which yields: TypeError("'_Environ' object is not callable",) Dave already told yo

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Lele Gaifax
Benjamin Kaplan writes: >> FYI, your code above is (almost) exactly equivalent to the simpler > > They aren't equivalent. "except Exception" won't catch KeyboardInterrupt or > SystemExit or a few others that you really don't want to catch in a generic > error handler. You should almost never have

Re: How to make this faster

2013-07-05 Thread Oscar Benjamin
On 5 July 2013 09:22, Helmut Jarausch wrote: > Hi, > > I have coded a simple algorithm to solve a Sudoku (probably not the first > one). > Unfortunately, it takes 13 seconds for a difficult problem which is more than > 75 times slower > than the same algorithm coded in C++. > Is this to be expec

Re: How to make this faster

2013-07-05 Thread Helmut Jarausch
On Fri, 05 Jul 2013 10:38:35 +0100, Fábio Santos wrote: > [Skipping to bottleneck] > >> def find_good_cell() : > > In this function you are accessing global variables a lot of times. Since > accessing globals takes much more time than accessing locals, I advise you > to assign them to local name

Re: How to make this faster

2013-07-05 Thread Fábio Santos
On 5 Jul 2013 09:29, "Helmut Jarausch" wrote: > > Hi, > > I have coded a simple algorithm to solve a Sudoku (probably not the first one). > Unfortunately, it takes 13 seconds for a difficult problem which is more than 75 times slower > than the same algorithm coded in C++. > Is this to be expected

Re: Coping with cyclic imports

2013-07-05 Thread Oscar Benjamin
On 5 July 2013 02:24, Cameron Simpson wrote: > On 04Jul2013 16:03, Oscar Benjamin wrote: > | > | Is there some reason you're responding to a post from 5 years ago? > > Is there some reason not to, if no newer solutions are available? No, I was genuinely curious. My way of accessing this forum/ne

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 12:21 μμ, ο/η Dave Angel έγραψε: On 07/05/2013 04:49 AM, Νίκος Gr33k wrote: I don't think running it via 'cli' would help much, since its a cgi-script and ip addr function have no meaning calling them in plain our of a cgi environment but here it is: No idea how to pa

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Dave Angel
On 07/05/2013 04:49 AM, Νίκος Gr33k wrote: I don't think running it via 'cli' would help much, since its a cgi-script and ip addr function have no meaning calling them in plain our of a cgi environment but here it is: No idea how to parse "have no meaning calling them in plain our of

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 11:27 πμ, ο/η Dave Angel έγραψε: Or if the problems cannot be recreated outside the cgi environment, use the log files you've been logging other problems into. Or simply open a text file for writing, and add a file= keyword parameter to the print function call. print(repr(e

Re: question please

2013-07-05 Thread Dave Angel
On 07/05/2013 03:48 AM, bill papanastasiou wrote: hello , good morning how i can pùt one python file in website ? Whose website? If it's your own, log into the server, and use cp. Or if you're remote with ssh access, use scp. And if you really have a bunch of files to remotely transfer, u

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Νίκος Gr33k
Στις 5/7/2013 11:35 πμ, ο/η Dave Angel έγραψε: On 07/05/2013 04:00 AM, Νίκος Gr33k wrote: Στις 5/7/2013 10:50 πμ, ο/η Dave Angel έγραψε: The line started as: > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] refactor that to: remadd = os.environ('REMOVE_ADDR')

Re: question please

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 09:48:09 +0200, bill papanastasiou wrote: > hello , good morning > > how i can pùt one python file in website ? The same way you would put any other file in a website. Can you be more specific? What website do you want to put it on? Is it your website or somebody else's?

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread feedthetroll
Am Freitag, 5. Juli 2013 10:00:21 UTC+2 schrieb Νίκος Gr33k: > ... > I'am not sure how iam supposed to write this: i just tried this: > try: > remadd = os.environ('REMOVE_ADDR') > tuple3 = socket.gethostbyaddr(remadd) > host = tuple3[0] > except: > host = type(remadd) + " :

Re: How is this evaluated

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 17:05:49 +1000, Chris Angelico wrote: > On Fri, Jul 5, 2013 at 11:41 AM, Steven D'Aprano > wrote: >> If you know C, that's like: >> >> ?(condition-being-tested, value-if-true, value-if-false) > > Or to be precise: > > condition-being-tested ? value-if-true : value-if-fal

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Dave Angel
On 07/05/2013 04:00 AM, Νίκος Gr33k wrote: Στις 5/7/2013 10:50 πμ, ο/η Dave Angel έγραψε: The line started as: > host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] refactor that to: remadd = os.environ('REMOVE_ADDR') tuple3 = socket.gethostbyaddr(remadd)

Re: Important features for editors

2013-07-05 Thread feedthetroll
Am Donnerstag, 4. Juli 2013 11:14:38 UTC+2 schrieb Νίκος Gr33k: > ... >> On 07/04/2013 03:59 AM, Νίκος wrote: >>> ... >>> Download Sublime Text v3 >>> Is a great editor >>> ... > > If you guys want to use it i can send you a patch for it. > I know its illegal thing to say but it will help you use

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-05 Thread Dave Angel
On 07/05/2013 03:13 AM, Νίκος Gr33k wrote: Στις 5/7/2013 10:06 πμ, ο/η Lele Gaifax έγραψε: try: host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] except: host = "Reverse DNS Failed" Yes i uses to had it like that, until i was looking for ways to make it h

  1   2   >