Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, MRAB wrote: > There's also a mistake in this bit: > > """ > # Note that according to the \u escaping convention, a supplemental > character (> 0x10) is represented > # by a sequence of two surrogate characters: the first between D800 and > DBFF, and the second between DC00

Re: l = range(int(1E9))

2015-05-03 Thread Mark Lawrence
On 03/05/2015 12:30, Chris Angelico wrote: On Sun, May 3, 2015 at 9:16 PM, Steven D'Aprano wrote: On Sun, 3 May 2015 12:16 pm, Mark Lawrence wrote: I doubt that six will ever make the standard library as 2.7 only has another five years in official support. By that time I suppose we'll to goi

Re: Python xlrd

2015-05-03 Thread Dan Sommers
On Sun, 03 May 2015 10:33:25 -0700, lbertolotti wrote: > lucas@lucas-K55VD:~$ dpkg -l python-xlrd > Desired=Unknown/Install/Remove/Purge/Hold > | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend > |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) > ||/ Name

Re: ImportPython Newsletter

2015-05-03 Thread Terry Reedy
On 5/3/2015 12:01 PM, Ankur Gupta wrote: Hey Guys, Just like to draw attention to ImportPython a weekly Python newsletter. This is the 30th issue of the newsletter http://importpython.com/newsletter/no/30/. Nice, but when I tried to subscribe, "Unable to reach server" -- Terry Jan Reedy -- h

Re: Python xlrd

2015-05-03 Thread lbertolotti via Python-list
lucas@lucas-K55VD:~$ dpkg -l python-xlrd Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==-==

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread MRAB
On 2015-05-03 17:26, Jon Ribbens wrote: On 2015-05-03, MRAB wrote: On 2015-05-03 16:32, Jon Ribbens wrote: That would, unfortunately, be "tell the Unicode Consortium to format their documents differently", which seems unlikely to happen. I'm trying to read in: http://www.unicode.org/Public/idn

EuroPython 2015: Financial Aid Program launched

2015-05-03 Thread M.-A. Lemburg
We are happy to announce a program for people in need of financial aid to attend EuroPython. You can find all the details on our financial aid page: *** Financial Aid Program *** https://ep2015.europython.eu/en/financial-aid/ In short, we will be giving out

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Chris Angelico
On Mon, May 4, 2015 at 2:30 AM, Jon Ribbens wrote: > I did some experimentation, and it looks like the answer is: > > "\udb40\udd9d".encode("utf16", "surrogatepass").decode("utf16") > > Thanks for your help! Ha! That's the one. I went poking around but couldn't find the name for it. That's exac

Re: Best way to use globally format

2015-05-03 Thread Ben Bacarisse
Cecil Westerhof writes: > I have a file where I used a lot of {0}, {1} and {2}. Most but not all > are changed to {0:.3E}, {1:.3E} and {2:.3E}. But when I want to change > the format I come in dependency hell. > > I could do something like: > format = ':.3E' > fmt0 = '{0' + format + '}

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, Chris Angelico wrote: > On Mon, May 4, 2015 at 1:32 AM, Jon Ribbens > wrote: >> That would, unfortunately, be "tell the Unicode Consortium to format >> their documents differently", which seems unlikely to happen. I'm >> trying to read in: http://www.unicode.org/Public/idna/6.3.0/Id

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, MRAB wrote: > On 2015-05-03 16:32, Jon Ribbens wrote: >> That would, unfortunately, be "tell the Unicode Consortium to format >> their documents differently", which seems unlikely to happen. I'm >> trying to read in: http://www.unicode.org/Public/idna/6.3.0/IdnaTest.txt >> > That do

Re: Best way to use globally format

2015-05-03 Thread Peter Otten
Cecil Westerhof wrote: > I have a file where I used a lot of {0}, {1} and {2}. Most but not all > are changed to {0:.3E}, {1:.3E} and {2:.3E}. But when I want to change > the format I come in dependency hell. > > I could do something like: > format = ':.3E' > fmt0 = '{0' + format + '} >

ImportPython Newsletter

2015-05-03 Thread Ankur Gupta
Hey Guys, Just like to draw attention to ImportPython a weekly Python newsletter. This is the 30th issue of the newsletter http://importpython.com/newsletter/no/30/. Check out a listing of all Python Books here http://importpython.com/books/ Thanks, Ankur -- https://mail.python.org/mailman/lis

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread MRAB
On 2015-05-03 16:32, Jon Ribbens wrote: On 2015-05-03, Chris Angelico wrote: On Mon, May 4, 2015 at 12:40 AM, Jon Ribbens wrote: If I have a string containing surrogate pairs like this in Python 3.4: "\udb40\udd9d" How do I convert it into the proper form: "\U000E019D" ? The answer ap

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-03 Thread vasudevram
On Sunday, May 3, 2015 at 6:38:28 PM UTC+5:30, Chris Angelico wrote: > On Sun, May 3, 2015 at 10:59 PM, vasudevram wrote: > > Re. statement of fact vs. hypotheses. While I'm not sure of your exact > > meaning in that paragraph, I understand the concept, and yes, I was not > > clear enough in phr

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Chris Angelico
On Mon, May 4, 2015 at 1:32 AM, Jon Ribbens wrote: >> You shouldn't even actually _have_ those in your string in the first >> place. How did you construct/receive that data? Ideally, catch it at >> that point, and deal with it there. > > That would, unfortunately, be "tell the Unicode Consortium t

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Marko Rauhamaa
Jon Ribbens : > Python doesn't appear to have UCS-2 support, so I guess what you're > saying is that I have to write my own surrogate-decoder? This seems a > little surprising. Try UTF-16. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, Chris Angelico wrote: > On Mon, May 4, 2015 at 12:40 AM, Jon Ribbens > wrote: >> If I have a string containing surrogate pairs like this in Python 3.4: >> >> "\udb40\udd9d" >> >> How do I convert it into the proper form: >> >> "\U000E019D" >> >> ? The answer appears not to be "u

Best way to use globally format

2015-05-03 Thread Cecil Westerhof
I have a file where I used a lot of {0}, {1} and {2}. Most but not all are changed to {0:.3E}, {1:.3E} and {2:.3E}. But when I want to change the format I come in dependency hell. I could do something like: format = ':.3E' fmt0 = '{0' + format + '} fmt1 = '{1' + format + '} fmt

Re: Throw the cat among the pigeons

2015-05-03 Thread Cecil Westerhof
Op Saturday 2 May 2015 16:20 CEST schreef Cecil Westerhof: > I am throwing the cat among the pigeons. ;-) > > In another thread I mentioned that I liked to have tail recursion in > Python. To be clear not automatic, but asked for. > > Looking at the replies I did hit a nerve. But I still want to >

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Chris Angelico
On Mon, May 4, 2015 at 12:40 AM, Jon Ribbens wrote: > If I have a string containing surrogate pairs like this in Python 3.4: > > "\udb40\udd9d" > > How do I convert it into the proper form: > > "\U000E019D" > > ? The answer appears not to be "unicodedata.normalize". No, it's not, because Unic

Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
If I have a string containing surrogate pairs like this in Python 3.4: "\udb40\udd9d" How do I convert it into the proper form: "\U000E019D" ? The answer appears not to be "unicodedata.normalize". -- https://mail.python.org/mailman/listinfo/python-list

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-03 Thread vasudevram
On Sunday, May 3, 2015 at 6:30:16 PM UTC+5:30, vasudevram wrote: > On Sunday, May 3, 2015 at 4:48:11 AM UTC+5:30, Terry Reedy wrote: > > On 5/2/2015 4:02 PM, vasudevram wrote: > > > Hi group, > > > > > > Please refer to this blog post about code showing that a Python data > > > structure can be sel

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 10:59 PM, vasudevram wrote: > Re. statement of fact vs. hypotheses. While I'm not sure of your exact > meaning in that paragraph, I understand the concept, and yes, I was not clear > enough in phrasing that part. It should have read like something along these > lines: > >

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-03 Thread vasudevram
On Sunday, May 3, 2015 at 4:48:11 AM UTC+5:30, Terry Reedy wrote: > On 5/2/2015 4:02 PM, vasudevram wrote: > > Hi group, > > > > Please refer to this blog post about code showing that a Python data > > structure can be self-referential: > > > > http://jugad2.blogspot.in/2015/05/can-python-data-stru

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Dave Angel
On 05/03/2015 05:22 AM, Cecil Westerhof wrote: Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney: Cecil Westerhof writes: When I have a value like 5.223701009526849e-05 in most cases I am not interested in all the digest after the dot. What type of value is it? If the absolute value is

Re: l = range(int(1E9))

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 9:16 PM, Steven D'Aprano wrote: > On Sun, 3 May 2015 12:16 pm, Mark Lawrence wrote: > >> I doubt that six will ever make the standard library as 2.7 only has >> another five years in official support. By that time I suppose we'll to >> going through the porting pain all ove

Re: l = range(int(1E9))

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 9:15 PM, Steven D'Aprano wrote: > Or if you prefer: > > try: > range = xrange > except NameError: > pass > > and just use range. I prefer this idiom, on the basis that code should be written for the more recent version, and have minimal code to support older version

Re: l = range(int(1E9))

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 02:51 pm, Ian Kelly wrote: > On Sat, May 2, 2015 at 5:51 PM, Terry Reedy wrote: >> On 5/2/2015 5:31 PM, Ian Kelly wrote: >> >>> Would it have been better if range() had been implemented as xrange() >>> from the beginning? Sure, that would have been great. Except for one >>> sma

Re: l = range(int(1E9))

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 12:16 pm, Mark Lawrence wrote: > I doubt that six will ever make the standard library as 2.7 only has > another five years in official support.  By that time I suppose we'll to > going through the porting pain all over again with the transition from > Python 3 to Python 4.  Alri

Re: l = range(int(1E9))

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 08:33 am, BartC wrote: > OK, so it's just an irritation then, as a workaround has been available > for a long time. (For example, if you use xrange, it won't work on 3.x. > If you use range, then it might be inefficient on 2.x.) That is trivially easy to deal with. Put this at

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 09:17 am, Terry Reedy wrote: > I believe that there was a time when printing a recursive structure hit > the recursion limit like your flatten did. But I will not reload 1.5 to > check. No, that was already fixed by 1.5: [steve@ando ~]$ python1.5 Python 1.5.2 (#1, Aug 27 2012,

Re: l = range(int(1E9))

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 07:40 am, Jon Ribbens wrote: > On 2015-05-02, BartC wrote: >> So do I, I think, if no-one is willing to admit that the original way of >> implementing range() was a glaring mistake. > > I think the issue is that nobody else here thinks the "original way" > of iterating was to

Re: code blocks

2015-05-03 Thread Ben Bacarisse
"Dr. John Q. Hacker" writes: > I'm thinking how interesting it would be to add code blocks to Python, > so that arbitrary strings of code can be passed around. It would open > up some interesting possibilities for self-modifying code and generic > programming. > > Since Python has already a pleth

Re: Is this a good way to implement testing

2015-05-03 Thread Cecil Westerhof
Op Sunday 3 May 2015 12:21 CEST schreef Mark Lawrence: >> That looks very promising. But I use the test to verify the >> correctness and show the performance. Is that also possible? Or >> should I split those out. >> > > Get it working correctly and if it's fast enough for your needs then > job do

Re: l = range(int(1E9))

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 8:32 PM, Steven D'Aprano wrote: > scripting > languages often lack a C-style for-loop, using a foreach loop instead. E.g. > I believe the canonical way to loop in bash is something like: > > for $i in `seq start stop` do ... > > (by memory). Newer versions of bash have

Re: l = range(int(1E9))

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 07:28 am, Tony the Tiger wrote: > On Fri, 01 May 2015 14:42:04 +1000, Steven D'Aprano wrote: > >> use "l" as a variable name, as it looks too much like 1 > > If you use a better font, they are very different. Besides, a variable > name cannot start with a digit (nor can it be

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 8:02 PM, Cecil Westerhof wrote: >>> If the absolute value is bigger as 0 and smaller as 1, it should be >>> a float. ;-) >> >> Or maybe a fractions.Fraction, or a decimal.Decimal, or a complex, >> or maybe a RXSTRING or a Gmp.mpf! There's more than one way to store >> a numb

Re: Inner workings of this Python feature: Can a Python data structure reference itself?

2015-05-03 Thread vasudevram
On Sunday, May 3, 2015 at 1:32:14 AM UTC+5:30, vasudevram wrote: > Hi group, > > Please refer to this blog post about code showing that a Python data > structure can be self-referential: > > http://jugad2.blogspot.in/2015/05/can-python-data-structure-reference.html > > Gotten a couple of commen

Re: l = range(int(1E9))

2015-05-03 Thread Steven D'Aprano
On Sun, 3 May 2015 02:17 am, BartC wrote: > But for looping over a simple integer range, then using 'range' to > denote the range (and build a list as it used to do), was how it was > done. And earlier on people would have been porting coding code to > Python at which point a straightforward 'for

Re: Messages with a time stamp

2015-05-03 Thread Cecil Westerhof
Op Sunday 3 May 2015 11:36 CEST schreef Mark Lawrence: > Rather than reinvent the wheel maybe you can pinch something from > here > https://docs.python.org/3/howto/logging-cookbook.html#logging-to-multiple-destinations That looks very promising. The only problem could be that it seems not to have

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Cecil Westerhof
Op Sunday 3 May 2015 11:51 CEST schreef Chris Angelico: > On Sun, May 3, 2015 at 7:22 PM, Cecil Westerhof wrote: >> Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney: >> >>> Cecil Westerhof writes: >>> When I have a value like 5.223701009526849e-05 in most cases I am not interested in

Re: Is this a good way to implement testing

2015-05-03 Thread Mark Lawrence
On 03/05/2015 10:49, Cecil Westerhof wrote: Op Sunday 3 May 2015 10:45 CEST schreef Peter Otten: Cecil Westerhof wrote: Another question. Is it acceptable to have it in the module itself, or should I put it in something like test_.py? The code for testing is bigger as the code for the impleme

Re: Is this a good way to implement testing

2015-05-03 Thread Cecil Westerhof
Op Sunday 3 May 2015 10:45 CEST schreef Peter Otten: > Cecil Westerhof wrote: > >> Another question. Is it acceptable to have it in the module itself, >> or should I put it in something like test_.py? The code for >> testing is bigger as the code for the implementation, so I am >> leaning to putti

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Chris Angelico
On Sun, May 3, 2015 at 7:22 PM, Cecil Westerhof wrote: > Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney: > >> Cecil Westerhof writes: >> >>> When I have a value like 5.223701009526849e-05 in most cases I am >>> not interested in all the digest after the dot. >> >> What type of value is it? >

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Cecil Westerhof
Op Sunday 3 May 2015 10:40 CEST schreef Ben Finney: > Cecil Westerhof writes: > >> When I have a value like 5.223701009526849e-05 in most cases I am >> not interested in all the digest after the dot. > > What type of value is it? If the absolute value is bigger as 0 and smaller as 1, it should b

Re: Messages with a time stamp

2015-05-03 Thread Mark Lawrence
On 03/05/2015 09:22, Cecil Westerhof wrote: For testing I want my messages time stamped like: 02:06:32: Check that the non recursive variants give the same value from 1000 upto 10 step 1000 02:06:32: Currently at1000 02:06:33: Currently at 11000 02:06:35: Currently

Re: Is this a good way to implement testing

2015-05-03 Thread Peter Otten
Terry Reedy wrote: > On 5/2/2015 6:29 PM, Cecil Westerhof wrote: > >> At the moment I define the test functionality in the following way: > > Any automated testing is better than none. For idlelib, I use unittest. > For an individual project with specialized needs, I use a custom test > frame

Re: Messages with a time stamp

2015-05-03 Thread Michiel Overtoom
On May 3, 2015, at 10:22, Cecil Westerhof wrote: > For testing I want my messages time stamped like: For progress reporting, I often use the module below (eta.py), which also gives a projected time of completion: import datetime, time, sys etastart = 0 def eta(done, total, s, reportinterval=1

Re: Is this a good way to implement testing

2015-05-03 Thread Ben Finney
Peter Otten <__pete...@web.de> writes: > Be aware that there is also doctest which scans docstrings for text > resembling interactive Python sessions. Doctests are both tests and > usage examples, so I think it's good to put a few of these into the > module. Yes, it's definitely a good idea to pu

Messages with a time stamp

2015-05-03 Thread Cecil Westerhof
For testing I want my messages time stamped like: 02:06:32: Check that the non recursive variants give the same value from 1000 upto 10 step 1000 02:06:32: Currently at1000 02:06:33: Currently at 11000 02:06:35: Currently at 21000 02:06:42: Currently at 31000

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Ben Finney
Ben Finney writes: > Assuming we're talking about a ‘float’ value:: > > >>> foo = 5.223701009526849e-05 > >>> "{foo:5.1}".format(foo=foo) > '5e-05' That's not as clear as it could be. Better is to be explicit about choosing “exponential” format:: >>> foo = 5.223701009526849e-05

Re: Is this a good way to implement testing

2015-05-03 Thread Peter Otten
Cecil Westerhof wrote: > Another question. Is it acceptable to have it in the module itself, or > should I put it in something like test_.py? The code for > testing is bigger as the code for the implementation, so I am leaning > to putting it in a separate file. Definitely use an established test

Re: Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Ben Finney
Cecil Westerhof writes: > When I have a value like 5.223701009526849e-05 in most cases I am not > interested in all the digest after the dot. What type of value is it? A ‘float’ value has many different textual representations, most of them inaccurate. So talking about the digits of a ‘float’ v

Re: Is this a good way to implement testing

2015-05-03 Thread Mark Lawrence
On 03/05/2015 08:36, Cecil Westerhof wrote: Thanks for the tips. For most I have to read a ‘little’ first, so I will not implement them immediately. Another question. Is it acceptable to have it in the module itself, or should I put it in something like test_.py? The code for testing is bigger a

Converting 5.223701009526849e-05 to 5e-05

2015-05-03 Thread Cecil Westerhof
When I have a value like 5.223701009526849e-05 in most cases I am not interested in all the digest after the dot. Is there a simple way to convert it to a string like '5e-05'? I could do something like: def format_small_number(n): abs_n = abs(n) assert (abs_n < 1) and (abs_n > 0

Re: Is this a good way to implement testing

2015-05-03 Thread Cecil Westerhof
Op Sunday 3 May 2015 00:29 CEST schreef Cecil Westerhof: > Still on my journey to learn Python. > > At the moment I define the test functionality in the following way: > if __name__ == '__main__': > keywords= [ > 'all', > 'factorial', > 'fibonacci', > 'happy', > 'lucky', > ] > keywords_msg