Re: Understanding other people's code

2013-07-14 Thread CM
> Basically the problem is I am new to the language and this was clearly > written by someone who at the moment is far better at it than I am! Sure, as a beginner, yes, but also it sounds like the programmer didn't document it much at all, and that doesn't help you. I bet s/he didn't always us

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread Terry Reedy
On 7/13/2013 11:09 PM, vek.m1...@gmail.com wrote: http://stackoverflow.com/questions/17632246/beazley-4e-p-e-r-page29-unicode Is this David Beazley? (You referred to 'DB' later.) "directly writing a raw UTF-8 encoded string such as 'Jalape\xc3\xb1o' simply produces a nine-character string U+

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread Joshua Landau
On 14 July 2013 04:09, wrote: > http://stackoverflow.com/questions/17632246/beazley-4e-p-e-r-page29-unicode > > "directly writing a raw UTF-8 encoded string such as 'Jalape\xc3\xb1o' simply > produces a nine-character string U+004A, U+0061, U+006C, U+0061, U+0070, > U+0065, U+00C3, U+00B1, U+00

Re: GeoIP2 for retrieving city and region ?

2013-07-14 Thread Νικόλας
Στις 14/7/2013 8:24 πμ, ο/η Chris Angelico έγραψε: On Sun, Jul 14, 2013 at 3:18 PM, ��� wrote: Can we get the location serived from lat/long coordinates? Yes, assuming you get accurate latitude and longitude, so you're back to square 1. ChrisA Dear Freelance, Thank you for your inte

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread vek . m1234
thank you (both of you) I follow now :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread Steven D'Aprano
On Sat, 13 Jul 2013 20:09:31 -0700, vek.m1234 wrote: > http://stackoverflow.com/questions/17632246/beazley-4e-p-e-r-page29- unicode > > "directly writing a raw UTF-8 encoded string such as 'Jalape\xc3\xb1o' > simply produces a nine-character string U+004A, U+0061, U+006C, U+0061, > U+0070, U+0065

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread wxjmfauth
Le samedi 13 juillet 2013 21:02:24 UTC+2, Dave Angel a écrit : > On 07/13/2013 10:37 AM, wxjmfa...@gmail.com wrote: > > > > > > Fortunately for us, Python (in version 3.3 and later) and Pike did it > > right. Some day the others may decide to do similarly. > > > --- Possible but

Re: Beazley 4E P.E.R, Page29: Unicode

2013-07-14 Thread vek . m1234
Hello Steven, a 'thank you' sounds insufficient and largely disproportionate to to the time and energy you spent in drafting a thoroughly comprehensive answer to my question. I've cross posted both answers to stackoverflow (with some minor formatting changes). I'll try to do something nice on yo

Re: [Python-ideas] float('∞')=float('inf')

2013-07-14 Thread Serhiy Storchaka
14.07.13 06:09, Chris Angelico написав(ла): Incidents like this are a definite push, but my D&D campaign is demanding my attention right now, so I haven't made the move. Are you role-playing Chaos Mage [1]? [1] http://www.dandwiki.com/wiki/Chaos_Mage_(3.5e_Class) -- http://mail.python.org/mai

Re: [Python-ideas] float('∞')=float('inf')

2013-07-14 Thread Chris Angelico
On Sun, Jul 14, 2013 at 8:23 PM, Serhiy Storchaka wrote: > 14.07.13 06:09, Chris Angelico написав(ла): > >> Incidents like this are a definite push, but my D&D campaign is >> demanding my attention right now, so I haven't made the move. > > > Are you role-playing Chaos Mage [1]? > > [1] http://www

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread Steven D'Aprano
On Sun, 14 Jul 2013 01:20:33 -0700, wxjmfauth wrote: > For a very simple reason, the latin-1 block: considered and accepted > today as beeing a Unicode design mistake. Latin-1 (also known as ISO-8859-1) was based on DEC's "Multinational Character Set", which goes back to 1983. ISO-8859-1 was fir

How to internationalize a python script? (i18n)

2013-07-14 Thread gialloporpora
Hello, I am trying to internationalize a script. First I have tried with a little script to understand how it works, but unfortunately, it doesn't. I have followed instruction in this page: http://docs.python.org/2/library/i18n.html I have created my script, marked strings with the _() functio

Re: hex dump w/ or w/out utf-8 chars

2013-07-14 Thread wxjmfauth
Le dimanche 14 juillet 2013 12:44:12 UTC+2, Steven D'Aprano a écrit : > On Sun, 14 Jul 2013 01:20:33 -0700, wxjmfauth wrote: > > > > > For a very simple reason, the latin-1 block: considered and accepted > > > today as beeing a Unicode design mistake. > > > > Latin-1 (also known as ISO-8859-

Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Chris Angelico
On Sun, Jul 14, 2013 at 11:44 PM, wrote: > Le dimanche 14 juillet 2013 12:44:12 UTC+2, Steven D'Aprano a écrit : >> On Sun, 14 Jul 2013 01:20:33 -0700, wxjmfauth wrote: >> >> >> >> > For a very simple reason, the latin-1 block: considered and accepted >> >> > today as beeing a Unicode design mist

Re: How to internationalize a python script? (i18n)

2013-07-14 Thread gialloporpora
Risposta al messaggio di gialloporpora : gettext.translation('helloi18n', LOCALE_DIR, 'it') Ok, I have, with a little help of my friend, found the issue. The language code must be passed as a list not as a string. Sorry. Sandro -- *Thunderbird come evitare il circolo vizioso “Re: R:” n

List comp help

2013-07-14 Thread Joseph L. Casale
I have a dict of lists. I need to create a list of 2 tuples, where each tuple is a key from the dict with one of the keys list items. my_dict = { 'key_a': ['val_a', 'val_b'], 'key_b': ['val_c'], 'key_c': [] } [(k, x) for k, v in my_dict.items() for x in v] This works, but I need to t

Re: List comp help

2013-07-14 Thread Chris Angelico
On Mon, Jul 15, 2013 at 3:10 AM, Joseph L. Casale wrote: > I have a dict of lists. I need to create a list of 2 tuples, where each tuple > is a key from > the dict with one of the keys list items. > > my_dict = { > 'key_a': ['val_a', 'val_b'], > 'key_b': ['val_c'], > 'key_c': [] > } >

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

2013-07-14 Thread Giorgos Tzampanakis
On 2013-07-12, Steven D'Aprano wrote: > On Thu, 11 Jul 2013 09:45:33 -0400, Roy Smith wrote: > >> In article <2fdf282e-fd28-4ba3-8c83-ce120...@googlegroups.com>, >> jus...@zeusedit.com wrote: >> >>> On Wednesday, July 10, 2013 2:17:12 PM UTC+10, Xue Fuqiao wrote: >>> >>> > * It is especiall

RE: List comp help

2013-07-14 Thread Joseph L. Casale
> Yeah, it's remarkably easy too! Try this: > > [(k, x) for k, v in my_dict.items() for x in v or [None]] > > An empty list counts as false, so the 'or' will then take the second option, > and iterate over the one-item list with > > None in it. Right, I overlooked that! Much appreciated, jlc --

Re: RE Module Performance

2013-07-14 Thread 88888 Dihedral
On Saturday, July 13, 2013 1:37:46 PM UTC+8, Steven D'Aprano wrote: > On Fri, 12 Jul 2013 13:58:29 -0400, Devyn Collier Johnson wrote: > > > > > I plan to spend some time optimizing the re.py module for Unix systems. > > > I would love to amp up my programs that use that module. > > > > In m

Re: List comp help

2013-07-14 Thread rurpy
On 07/14/2013 11:16 AM, Chris Angelico wrote: > On Mon, Jul 15, 2013 at 3:10 AM, Joseph L. Casale > wrote: >> I have a dict of lists. I need to create a list of 2 tuples, where each >> tuple is a key from >> the dict with one of the keys list items. >> >> my_dict = { >> 'key_a': ['val_a', 'va

Re: List comp help

2013-07-14 Thread rurpy
On Sunday, July 14, 2013 12:32:34 PM UTC-6, ru...@yahoo.com wrote: > Or more simply: > [(k, v or None) for k, v in my_dict.items()] Too simply :-( Didn't read the op carefully enough. Sorry. -- http://mail.python.org/mailman/listinfo/python-list

Re: GeoIP2 for retrieving city and region ?

2013-07-14 Thread Tim Chase
On 2013-07-13 16:57, Michael Torrie wrote: > On 07/13/2013 12:23 PM, Νικόλας wrote: > > Do you know a way of implementing anyone of these methods to a > > script? > > Yes. Modern browsers all support a location API in the browser for > javascript. And the good browsers give the user the option

Re: Ideal way to separate GUI and logic?

2013-07-14 Thread fronagzen
Thanks for all the responses! So as a general idea, I should at the very least separate the GUI from the program logic by defining the logic as a function, correct? And the next level of separation is to define the logic as a class in one or more separate files, and then import it to the file w

Re: Ideal way to separate GUI and logic?

2013-07-14 Thread fronagzen
Thanks for all the responses! So as a general idea, I should at the very least separate the GUI from the program logic by defining the logic as a function, correct? And the next level of separation is to define the logic as a class in one or more separate files, and then import it to the file w

Re: Ideal way to separate GUI and logic?

2013-07-14 Thread Joel Goldstick
On Sun, Jul 14, 2013 at 8:25 PM, wrote: > Thanks for all the responses! > > So as a general idea, I should at the very least separate the GUI from the > program logic by defining the logic as a function, correct? And the next > level of separation is to define the logic as a class in one or more

Re: Ideal way to separate GUI and logic?

2013-07-14 Thread Roy Smith
In article , Joel Goldstick wrote: > Writing code isn't all theory. It takes practice, and since the days > of The Mythical Man-Month, it has been well understood that you > always end up throwing away the first system anyway. If I may paraphrase Brooks, "Plan to throw the first one away, be

Re: Ideal way to separate GUI and logic?

2013-07-14 Thread Steven D'Aprano
On Sun, 14 Jul 2013 17:25:32 -0700, fronagzen wrote: > My next question is, to what degree should I 'slice' my logic into > functions? How small or how large should one function be, as a rule of > thumb? I aim to keep my functions preferably below a dozen lines (excluding the doc string), and de

what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Gildor Oronar
A currency exchange thread updates exchange rate once a minute. If the thread faield to update currency rate for 5 hours, it should inform main() for a clean exit. This has to be done gracefully, because main() could be doing something delicate. I, a newbie, read all the thread sync tool, and

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread zhangweiwu
On Monday, July 15, 2013 10:27:45 AM UTC+8, Gildor Oronar wrote: > What is the professional way in this case? Hi. I am not a professional neither but I think a professional does this: class CurrencyExchange(): def __init__(in_case_callback): this.callback = in_case_callback def __r

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Steven D'Aprano
On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: > A currency exchange thread updates exchange rate once a minute. If the > thread faield to update currency rate for 5 hours, it should inform > main() for a clean exit. This has to be done gracefully, because main() > could be doing somethi

Re: what thread-synch mech to use for clean exit from a thread

2013-07-14 Thread Steven D'Aprano
Oh, I forgot another comment... On Mon, 15 Jul 2013 03:04:14 +, Steven D'Aprano wrote: > On Mon, 15 Jul 2013 10:27:45 +0800, Gildor Oronar wrote: >>while time.time() - self.rate_timestamp < 5*3600: >> ... # update exchange rate >> if success: >> self.

SMITHSONIAN HAS IT'S LAST WORDS...

2013-07-14 Thread LOUZY
=== A TOUCHY SUBJECT... === > A WILY THRINAXODON SUED THE SMITHSONIAN FIVE HUNDRED DOLLARS FOR SUPPRESSION OF FREEDOM OF EXPRESSION. > "This is a blow to evolutionism," SAID RICHARD DAWKINS. > ONE WHOM THRINAXODON HAS HAD SEVERAL *long* RUNNING FEUDS OVER

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Terry Reedy
On 7/14/2013 10:56 AM, Chris Angelico wrote: On Sun, Jul 14, 2013 at 11:44 PM, wrote: timeit.repeat("a = 'hundred'; 'x' in a") [0.11785943134991479, 0.09850454944486256, 0.09761604599423179] timeit.repeat("a = 'hundreœ'; 'x' in a") [0.23955250303158593, 0.2195812612416752, 0.2213389699740

Re: Timing of string membership (was Re: hex dump w/ or w/out utf-8 chars)

2013-07-14 Thread Chris Angelico
On Mon, Jul 15, 2013 at 2:18 PM, Terry Reedy wrote: > On 7/14/2013 10:56 AM, Chris Angelico wrote: > As issue about finding stings in strings was opened last September and, as > reported on this list, fixes were applied about last March. As I remember, > some but not all of the optimizations were

Re: List comp help

2013-07-14 Thread Terry Reedy
On 7/14/2013 1:10 PM, Joseph L. Casale wrote: I have a dict of lists. I need to create a list of 2 tuples, where each tuple is a key from the dict with one of the keys list items. my_dict = { 'key_a': ['val_a', 'val_b'], 'key_b': ['val_c'], 'key_c': [] } [(k, x) for k, v in my_di