Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 17:04:55 +1100, Chris Angelico wrote: On Tue, Mar 4, 2014 at 4:35 PM, Steven D'Aprano st...@pearwood.info wrote: On Tue, 04 Mar 2014 05:37:27 +1100, Chris Angelico wrote: x = 23 # Compiler goes: Okay, x takes ints. x += 5 # Compiler: No prob, int += int -- int x = str(x)

Decoding a process output

2014-03-04 Thread Francis Moreau
Hi, In my understanding (I'm relatively new to python), I need to decode any bytes data provided, in my case, by a shell command (such as findmnt) started by the subprocess module. The goal of my application is to parse the command outputs. My application runs only on linux BTW and should run

Re: Functional programming

2014-03-04 Thread BartC
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote in message news:5314bb96$0$29985$c3e8da3$54964...@news.astraweb.com... Think about the sort of type declarations you have to do in (say) Pascal, and consider how stupid the compiler must be: function add_one(x: integer):integer; begin

Python 2.7 documentation with readthedocs theme

2014-03-04 Thread Charles Gunawan
Hi, I was just looking into some documentation on readthedocs and I saw that they have a cool new theme. I was wondering how the python documentation will look like with that theme. So after some tinkering I have build python 2.7 CHM documentation with the theme. If you are wondering too you

Logging

2014-03-04 Thread Igor Korot
Hi, ALL, Could someone please explain to me how the code in http://docs.python.org/2/howto/logging#logging-from-multiple-modules works? In particular I'm interested in how the mylib.py knows about the myapp.log. What I mean is: logging object is not passed to mylib.py, so essentially it should

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-04 Thread Jaap van Wingerde
Op 2014-03-03T12:22:48 UTC schreef donarb don...@nwlink.com in het bericht Re: modification time in Python - Django: datetime != datetime :-(, ID: 04659633-e14e-4d5b-90f2-93af04f05...@googlegroups.com het volgende. You're using the months format '%m' when you should be using minutes '%M'.

Re: Functional programming

2014-03-04 Thread Antoon Pardon
Op 04-03-14 09:56, Steven D'Aprano schreef: If you explicitly say that this is an int, then yes, that should be disallowed; It's that explicitly part that doesn't follow. Having to manage types is the most tedious, boring, annoying, *unproductive* part of languages like Java, C and

Re: why indentation should be part of the syntax

2014-03-04 Thread Antoon Pardon
Op 02-03-14 11:41, Stefan Behnel schreef: Haven't seen any mention of it on this list yet, but since it's such an obvious flaw in quite a number of programming languages, here's a good article on the recent security bug in iOS, which was due to accidentally duplicated code not actually being

Re: Working with the set of real numbers

2014-03-04 Thread Gregory Ewing
Chris Angelico wrote: In constant space, that will produce the sum of two infinite sequences of digits. It's not constant space, because the nines counter can grow infinitely large. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-04 Thread Alister
On Tue, 04 Mar 2014 09:18:57 +1100, Ben Finney wrote: Marko Rauhamaa ma...@pacujo.net writes: Mark Lawrence breamore...@yahoo.co.uk: I'd just like to know why people are so obsessed with identities, I've never thought to use them in 10+ years of writing Python. Do I use the KISS

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-04 Thread Ian Kelly
On Mon, Mar 3, 2014 at 11:35 PM, Chris Angelico ros...@gmail.com wrote: In constant space, that will produce the sum of two infinite sequences of digits. (And it's constant time, too, except when it gets a stream of nines. Adding three thirds together will produce an infinite loop as it waits

Re: Working with the set of real numbers (was: Finding size of Variable)

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 4:19 AM, Ian Kelly ian.g.ke...@gmail.com wrote: def cf_sqrt(n): Yield the terms of the square root of n as a continued fraction. m = 0 d = 1 a = a0 = floor_sqrt(n) while True: yield a next_m = d * a - m next_d = (n - next_m

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 11:56:07 +0100, Antoon Pardon wrote: Op 04-03-14 09:56, Steven D'Aprano schreef: If you explicitly say that this is an int, then yes, that should be disallowed; It's that explicitly part that doesn't follow. Having to manage types is the most tedious, boring,

Re: Reference

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 11:10:34 +, Alister wrote: Definition of insanity Doing the same thing over and over again expecting different results *rolls dice* :-) -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

find and replace string in binary file

2014-03-04 Thread loial
How do I read a binary file, find/identify a character string and replace it with another character string and write out to another file? Its the finding of the string in a binary file that I am not clear on. Any help appreciated -- https://mail.python.org/mailman/listinfo/python-list

Re: Working with the set of real numbers

2014-03-04 Thread Chris Angelico
On Tue, Mar 4, 2014 at 10:05 PM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Chris Angelico wrote: In constant space, that will produce the sum of two infinite sequences of digits. It's not constant space, because the nines counter can grow infinitely large. Okay, okay, technically

Re: Origin of 'self'

2014-03-04 Thread MRAB
On 2014-03-04 02:09, Dennis Lee Bieber wrote: On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez aniko...@gmail.com declaimed the following: I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can

Re: Reference

2014-03-04 Thread Alexander Blinne
Am 03.03.2014 19:48, schrieb Terry Reedy: The 'is' operator has three uses, two intended and one not. In production code, 'is' tests that an object *is* a particular singular object, such as None or a sentinel instance of class object. Just a bit of statistics on this one from a recent small

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Tue, Mar 4, 2014 at 10:47 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Not even close. I'd like to see the compiler that can work out for itself that this function is buggy: def sine_rule(side_a, side_b, angle_a): Return the angle opposite side_b. return

Re: find and replace string in binary file

2014-03-04 Thread MRAB
On 2014-03-04 12:27, loial wrote: How do I read a binary file, find/identify a character string and replace it with another character string and write out to another file? Its the finding of the string in a binary file that I am not clear on. Any help appreciated Read it in chunks and search

Re: find and replace string in binary file

2014-03-04 Thread Peter Otten
loial wrote: How do I read a binary file, find/identify a character string and replace it with another character string and write out to another file? Its the finding of the string in a binary file that I am not clear on. That's not possible. You have to convert either binary to string or

Re: Idle thread (Polling) python GUI and saving program state

2014-03-04 Thread MRAB
On 2014-03-04 02:41, Rolando wrote: On Monday, March 3, 2014 6:06:22 PM UTC-8, MRAB wrote: On 2014-03-04 01:33, Rolando wrote: I have a GUI with a bunch of cells which is my View in the MVC design. The user enters some information in the view and I pass this on to the model so that

Re: Functional programming

2014-03-04 Thread BartC
Steven D'Aprano st...@pearwood.info wrote in message news:53159540$0$2923$c3e8da3$76491...@news.astraweb.com... It's that explicitly part that doesn't follow. Having to manage types is the most tedious, boring, annoying, *unproductive* part of languages like Java, C and Pascal. Almost always,

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 12:30 AM, BartC b...@freeuk.com wrote: But declaring variables is not just about specifying a type; it registers the name too so that misspelled names can be picked up very early rather than at runtime (and that's if you're lucky). The two are separate. I don't know of

Re: Functional programming

2014-03-04 Thread Mark Lawrence
On 04/03/2014 13:30, BartC wrote: But declaring variables is not just about specifying a type; it registers the name too so that misspelled names can be picked up very early rather than at runtime (and that's if you're lucky). I've said before that this, to me, is one of the major downsides

Re: Reference

2014-03-04 Thread Chris Angelico
On Tue, Mar 4, 2014 at 11:55 PM, Alexander Blinne n...@blinne.net wrote: Am 03.03.2014 19:48, schrieb Terry Reedy: The 'is' operator has three uses, two intended and one not. In production code, 'is' tests that an object *is* a particular singular object, such as None or a sentinel instance of

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 1:05 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 04/03/2014 13:30, BartC wrote: But declaring variables is not just about specifying a type; it registers the name too so that misspelled names can be picked up very early rather than at runtime (and that's if

Re: Origin of 'self'

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 12:47:09 +, MRAB wrote: In AppleScript a script can refer to the title of a window as title of window or window's title, and it can refer to the title of its own window as title of window of me or me's window's title. Consistent, yes, but bad English. That's why I

OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Steven D'Aprano
On Wed, 05 Mar 2014 00:01:01 +1100, Chris Angelico wrote: On Tue, Mar 4, 2014 at 10:47 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Not even close. I'd like to see the compiler that can work out for itself that this function is buggy: def sine_rule(side_a, side_b,

Re: OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Tim Chase
On 2014-03-04 14:25, Steven D'Aprano wrote: Ask-me-about-versine-and-haversine-ly y'rs, More interested in a karosine, cuisine, and a limousine. ;-) -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Mark Lawrence
On 04/03/2014 14:37, Tim Chase wrote: On 2014-03-04 14:25, Steven D'Aprano wrote: Ask-me-about-versine-and-haversine-ly y'rs, More interested in a karosine, cuisine, and a limousine. ;-) -tkc What do you get if you differentiate versines, haversines, karosines, cuisines and limosines?

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 14:05:44 +, Mark Lawrence wrote: Once a statically typed language has been compiled the programmer can head down to the pub. It compiles? Quick! Ship it! Well, that certainly explains the quality of some programs... -- Steven D'Aprano

Re: Functional programming

2014-03-04 Thread Grant Edwards
On 2014-03-03, Ben Finney ben+pyt...@benfinney.id.au wrote: Gregory Ewing greg.ew...@canterbury.ac.nz writes: Just because the compiler *can* infer the return type doesn't necessarily mean it *should*. When I was playing around with functional languages, I ended up adopting the practice of

Re: OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 1:25 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The Sine Rule, or Law of Sines, tells us that the ratio of the length of a side and the sine of the angle opposite that side is constant for any triangle. That is: a/sin(A) == b/sin(B) == c/sin(C)

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 1:55 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 04 Mar 2014 14:05:44 +, Mark Lawrence wrote: Once a statically typed language has been compiled the programmer can head down to the pub. It compiles? Quick! Ship it! Well, that certainly

Re: Reference

2014-03-04 Thread Jerry Hill
On Mon, Mar 3, 2014 at 11:52 PM, Steven D'Aprano st...@pearwood.info wrote: If your intention is to treat None as a singleton sentinel, not as a value, then you ought to use is to signal that intention, rather than using == even if you know that there won't be any false positives. In all of

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 13:30:04 +, BartC wrote: Steven D'Aprano st...@pearwood.info wrote in message news:53159540$0$2923$c3e8da3$76491...@news.astraweb.com... It's that explicitly part that doesn't follow. Having to manage types is the most tedious, boring, annoying, *unproductive* part

Re: OT Sine Rule [was Re: Functional programming]

2014-03-04 Thread Tim Chase
On 2014-03-04 14:42, Mark Lawrence wrote: What do you get if you differentiate versines, haversines, karosines, cuisines and limosines? Well, with cuisines, you can usually differentiate by seasoning: your Tex/Mex is spicier and tends to have chili cumin, while your Indian tends to lean more

Re: how to get bytes from bytearray without copying

2014-03-04 Thread Juraj Ivančić
On 3.3.2014. 2:27, Ian Kelly wrote: Python 3.3 has a C API function to create a memoryview for a char*, that can be made read-only. http://docs.python.org/3/c-api/memoryview.html#PyMemoryView_FromMemory I don't see a way to do what you want in pure Python, apart from perhaps writing an

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 14:59:51 +, Grant Edwards wrote: After a couple decades of working in software development, I've decided that comments like that are not correct often enough to be useful. You've got to reverse-engineer the code if there's no such comment. If there _is_ a comment, you

Re: Reference

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 2:19 AM, Jerry Hill malaclyp...@gmail.com wrote: Out of curiosity, do you think we should be doing truth checking with 'is'? True and False are singletons, and it seems to me that the justification for idenity versus equality should be just as strong there, but I don't

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 2:18 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You don't need to have static typing to have declared variables. The two are independent. E.g. one might have a system like Python, except you have to declare your variables before using them: global x

Re: Logging

2014-03-04 Thread Peter Otten
Igor Korot wrote: Hi, ALL, Could someone please explain to me how the code in http://docs.python.org/2/howto/logging#logging-from-multiple-modules works? In particular I'm interested in how the mylib.py knows about the myapp.log. What I mean is: logging object is not passed to mylib.py,

Re: Reference

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 10:19:22 -0500, Jerry Hill wrote: On Mon, Mar 3, 2014 at 11:52 PM, Steven D'Aprano st...@pearwood.info wrote: If your intention is to treat None as a singleton sentinel, not as a value, then you ought to use is to signal that intention, rather than using == even if you

Re: Functional programming

2014-03-04 Thread Steven D'Aprano
On Wed, 05 Mar 2014 02:28:17 +1100, Chris Angelico wrote: On Wed, Mar 5, 2014 at 2:18 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You don't need to have static typing to have declared variables. The two are independent. E.g. one might have a system like Python, except you

Re: Reference

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 2:42 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: # I never know when to stop if bool(flag) is True is True is True is True is True is True: ... The banana problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 2:45 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Aside: If you declare your locals, you shouldn't need to declare your globals. Though I could imagine a rule that global rebinding still needs to be declared, but you certainly shouldn't need to declare

Re: Decoding a process output

2014-03-04 Thread Peter Otten
Francis Moreau wrote: Hi, In my understanding (I'm relatively new to python), I need to decode any bytes data provided, in my case, by a shell command (such as findmnt) started by the subprocess module. The goal of my application is to parse the command outputs. My application runs only

Re: Reference

2014-03-04 Thread Roy Smith
In article mailman.7726.1393948954.18130.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 2:42 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: # I never know when to stop if bool(flag) is True is True is True is True is True is True: ...

Re: how to get bytes from bytearray without copying

2014-03-04 Thread Stefan Behnel
Juraj Ivančić, 04.03.2014 16:23: Just for reference, it is doable in pure Python, with ctypes help For some questionable meaning of pure. Stefan -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-04 Thread Rustom Mody
On Tuesday, March 4, 2014 8:49:22 PM UTC+5:30, Jerry Hill wrote: On Mon, Mar 3, 2014 at 11:52 PM, Steven D'Aprano wrote: If your intention is to treat None as a singleton sentinel, not as a value, then you ought to use is to signal that intention, rather than using == even if you know that

Re: How security holes happen

2014-03-04 Thread sffjunkie
On Monday, 3 March 2014 22:55:32 UTC, Chris Kaynor wrote: You can go much simpler than that. Merely port Python to LISP, then write a LISP interpreter in Python. Done. http://blog.pault.ag/post/46982895940/heres-my-talk-from-pycon-2013-i-tried-to-queue --

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-04 Thread donarb
Note that it's bad form to post the same question to different forums, you also posted this question to django-users. By posting to multiple forums, you run the risk of not having the question answered or followed up in one of the forums. This frustrates other users who may one day have a

Re: Functional programming

2014-03-04 Thread MRAB
On 2014-03-04 15:13, Chris Angelico wrote: On Wed, Mar 5, 2014 at 1:55 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 04 Mar 2014 14:05:44 +, Mark Lawrence wrote: Once a statically typed language has been compiled the programmer can head down to the pub. It

Re: How security holes happen

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 3:41 AM, sffjun...@gmail.com wrote: On Monday, 3 March 2014 22:55:32 UTC, Chris Kaynor wrote: You can go much simpler than that. Merely port Python to LISP, then write a LISP interpreter in Python. Done.

Re: Origin of 'self'

2014-03-04 Thread MRAB
On 2014-03-04 14:27, Steven D'Aprano wrote: On Tue, 04 Mar 2014 12:47:09 +, MRAB wrote: In AppleScript a script can refer to the title of a window as title of window or window's title, and it can refer to the title of its own window as title of window of me or me's window's title.

Re: Reference

2014-03-04 Thread MRAB
On 2014-03-04 16:02, Chris Angelico wrote: On Wed, Mar 5, 2014 at 2:42 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: # I never know when to stop if bool(flag) is True is True is True is True is True is True: ... The banana problem. Speaking of which: The 'right' way to

Re: How security holes happen

2014-03-04 Thread Skip Montanaro
On Tue, Mar 4, 2014 at 11:07 AM, Chris Angelico ros...@gmail.com wrote: I don't have time to watch an hour-long video... what'd he do, exactly that? If you fast forward to 16:14, his talk is about five minutes long. He wrote a Lisp compiler whose backend is Python. Skip --

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-04 Thread Roy Smith
In article d6b15bdd-895c-4efd-bd1c-f682de13b...@googlegroups.com, donarb don...@nwlink.com wrote: Note that it's bad form to post the same question to different forums, you also posted this question to django-users. By posting to multiple forums, you run the risk of not having the question

Re: Working with the set of real numbers

2014-03-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: As far as I know, there's no simple way, in constant space and/or time, to progressively yield more digits of a number's square root, working in decimal. I don't know why the constant space/time requirement is crucial. Anyway, producing more digits simple:

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Antoon Pardon antoon.par...@rece.vub.ac.be: In the same way writing unit tests is the most tedious, boring, annoying, *unproductive* part. Amost always you are giving the program results it can work out for itself. Undoubtedly, explicit type declarations add a dimension of quality to

Re: Working with the set of real numbers

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: As far as I know, there's no simple way, in constant space and/or time, to progressively yield more digits of a number's square root, working in decimal. I don't know why the constant

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa ma...@pacujo.net wrote: public ConnectionPool(int maxConnections, String url) throws SQLException { try { super(() - { try { return DriverManager.getConnection(url); } catch ( SQLException ex )

NEW RESEARCH TEARS PALAEOANTHROPOLOGY APART: THE THRINAXODON TIMES

2014-03-04 Thread Thrinazodji0fecnfv
=== BREAKING NEWS! === NEW YORK TIMES, THRINAXODON, OHIO = THRINAXODON RECENTLY FOUND 3 HUMAN FOSSILS FROM DEVONIAN STRATA FROM GREENLAND, THE EVOLUTIONISTS HAVE NO BONES ABOUT. ONE EVIL EVOLUTIONIST, BOB CASANOVA HAS ADMITTED THAT HUMAN EVOLUTION

Re: How security holes happen

2014-03-04 Thread Ned Batchelder
On 3/4/14 12:16 PM, Skip Montanaro wrote: On Tue, Mar 4, 2014 at 11:07 AM, Chris Angelico ros...@gmail.com wrote: I don't have time to watch an hour-long video... what'd he do, exactly that? If you fast forward to 16:14, his talk is about five minutes long. He wrote a Lisp compiler whose

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa ma...@pacujo.net wrote: public ConnectionPool(int maxConnections, String url) throws SQLException { try { super(() - { try { return DriverManager.getConnection(url);

Proper conversion of timestamp

2014-03-04 Thread Igor Korot
Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with milliseconds into the datetime object. The first hit of Google gives me this: http://stackoverflow.com/questions/12458595/convert-epoch-timestamp-in-python but the

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 19:58, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: As far as I know, there's no simple way, in constant space and/or time, to progressively yield more digits of a number's square

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 7:50 AM, Marko Rauhamaa ma...@pacujo.net wrote: The rigmarole is trying to get around Java's mandatory exception handling limitations, which Python doesn't have. You are not allowed to pass a lambda to the super constructor that throws an SQLException. To get around the

Re: Working with the set of real numbers

2014-03-04 Thread Marko Rauhamaa
Oscar Benjamin oscar.j.benja...@gmail.com: To me the obvious method is Newton iteration which takes O(sqrt(N)) iterations to obtain N digits of precision. This brings the above complexity below quadratic: #!/usr/bin/env python from decimal import Decimal as D, localcontext def sqrt(y,

Re: Working with the set of real numbers

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: I don't quite follow your reasoning here. By cut-and-try do you mean bisection? If so it gives the first N decimal digits in N*log2(10) iterations. However each iteration requires a multiply and when the number of

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: Oh, it's THAT problem. Well, it's still not really a fair comparison of declared types. It shows how Python's much easier to work with, but what you're showing off is the simpler exception handling :) The other example I gave is really bread-and-butter Java.

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:21 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: Oh, it's THAT problem. Well, it's still not really a fair comparison of declared types. It shows how Python's much easier to work with, but what you're showing off is the simpler exception

Re: Proper conversion of timestamp

2014-03-04 Thread MRAB
On 2014-03-04 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with milliseconds into the datetime object. The first hit of Google gives me this:

Re: python decimal library dmath.py v0.3 released

2014-03-04 Thread Stefan Krah
[I found this via the python-ideas thread] Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de writes: math.factorial is accurate and faster than your pure-Python function, especially for large numbers. It is slower for huge numbers than decimal if you use this Python function:

Re: Proper conversion of timestamp

2014-03-04 Thread Mark Lawrence
On 04/03/2014 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with milliseconds into the datetime object. The first hit of Google gives me this:

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com: C++ at least has typedefs, and in the newer standards, the 'auto' keyword was repurposed. Last I checked, C++ had no satisfactory way to express callbacks/functors/listeners/lambdas. That's why Qt came up with a metacompiler to supplement C++'s facilities. No,

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
MRAB, On Tue, Mar 4, 2014 at 1:38 PM, MRAB pyt...@mrabarnett.plus.com wrote: On 2014-03-04 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with milliseconds into the datetime object.

Re: Proper conversion of timestamp

2014-03-04 Thread Mark Lawrence
On 04/03/2014 21:38, MRAB wrote: On 2014-03-04 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with milliseconds into the datetime object. The first hit of Google gives me this:

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:43 AM, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: C++ at least has typedefs, and in the newer standards, the 'auto' keyword was repurposed. Last I checked, C++ had no satisfactory way to express callbacks/functors/listeners/lambdas.

Re: Reference

2014-03-04 Thread Alexander Blinne
Am 04.03.2014 15:06, schrieb Chris Angelico: https://github.com/Rosuav/ExceptExpr/blob/master/find_except_expr.py I have always found it quite nice that the python parser is so easy to use from within python itself. Run across the Python stdlib, that tells me there are 4040 uses of is/is not,

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
Mark, On Tue, Mar 4, 2014 at 1:45 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 04/03/2014 21:38, MRAB wrote: On 2014-03-04 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
Hi, Mark, On Tue, Mar 4, 2014 at 1:44 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 04/03/2014 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() function trying to convert the timestamp with milliseconds into the datetime

Re: Proper conversion of timestamp

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:46 AM, Igor Korot ikoro...@gmail.com wrote: Are you using Python 2? If yes, then try dividing by 1000.0. Yes, I'm using python 2.7. But dividing by 1000 will give the precision in seconds, i.e. -MM-DD HH:MM:SS. Did you notice the bit at the end there? Try

Re: Reference

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:53 AM, Alexander Blinne n...@blinne.net wrote: Am 04.03.2014 15:06, schrieb Chris Angelico: https://github.com/Rosuav/ExceptExpr/blob/master/find_except_expr.py I have always found it quite nice that the python parser is so easy to use from within python itself. Yes.

Re: Proper conversion of timestamp

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:55 AM, Igor Korot ikoro...@gmail.com wrote: This is because this timestamp is not in seconds, but rather in milliseconds. Now the question I have is: how do I properly convert this timestamp into the datetime object with the milliseconds? Read elsewhere in the

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 21:18, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: I don't quite follow your reasoning here. By cut-and-try do you mean bisection? If so it gives the first N decimal digits in N*log2(10) iterations.

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 21:05, Marko Rauhamaa ma...@pacujo.net wrote: Oscar Benjamin oscar.j.benja...@gmail.com: To me the obvious method is Newton iteration which takes O(sqrt(N)) iterations to obtain N digits of precision. This brings the above complexity below quadratic: #!/usr/bin/env python

Re: Working with the set of real numbers

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 9:02 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 4 March 2014 21:18, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: I don't quite follow your reasoning here. By cut-and-try do you mean

Re: Proper conversion of timestamp

2014-03-04 Thread Ethan Furman
On 03/04/2014 01:55 PM, Igor Korot wrote: Now the question I have is: how do I properly convert this timestamp into the datetime object with the milliseconds? And Mark's point is: How do the docs say to do it? What fails when you try it that way? -- ~Ethan~ --

Re: How security holes happen

2014-03-04 Thread Ethan Furman
On 03/04/2014 12:47 PM, Ned Batchelder wrote: On 3/4/14 12:16 PM, Skip Montanaro wrote: On Tue, Mar 4, 2014 at 11:07 AM, Chris Angelico ros...@gmail.com wrote: I don't have time to watch an hour-long video... what'd he do, exactly that? If you fast forward to 16:14, his talk is about five

Re: find and replace string in binary file

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 12:18 AM, Peter Otten __pete...@web.de wrote: loial wrote: How do I read a binary file, find/identify a character string and replace it with another character string and write out to another file? Its the finding of the string in a binary file that I am not clear on.

Re: Proper conversion of timestamp

2014-03-04 Thread Mark Lawrence
On 04/03/2014 21:55, Igor Korot wrote: But this particular question is easy. If it's easy why can't you answer it via the docs rather than ask here? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is

Re: How security holes happen

2014-03-04 Thread Marko Rauhamaa
Ethan Furman et...@stoneleaf.us: Okay, that looks totally cool. Maybe I'll finally get a handle on LISP! :) Lisp is conceptually simpler than Python, but awe-inspiring. One day, it will overtake Python, I believe. Once you have Lisp down pat, you'll be able to appreciate URL:

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 22:18, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 9:02 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 4 March 2014 21:18, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

Re: How security holes happen

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 9:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Lisp is conceptually simpler than Python, but awe-inspiring. One day, it will overtake Python, I believe. The final Nirvana is reached with... No no no. The final Nirvana is achieved when you no longer write text at all,

Re: How security holes happen

2014-03-04 Thread Roy Smith
In article mailman.7763.1393973842.18130.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Wed, Mar 5, 2014 at 9:48 AM, Marko Rauhamaa ma...@pacujo.net wrote: Lisp is conceptually simpler than Python, but awe-inspiring. One day, it will overtake Python, I believe. The

Re: Working with the set of real numbers

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 9:54 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: Let's compare two versions. In the first, you set the precision (I'm talking in terms of REXX's NUMERIC DIGITS statement I have no idea what that is. - anything beyond this many digits will be rounded (and

Geezer learns python

2014-03-04 Thread notbob
I'm trying to learn python. I'm doing it via Zed Shaw's Learn Python the Hard Way. Sure enough, 16 lessons in and I've run aground. Is it OK for a painfully stupid ol' fart to ask painfully stupid noob questions, here? I'm a long time usenet fan and prefer it to irc. I've run Slackware for

Re: Geezer learns python

2014-03-04 Thread Tobiah
On 03/04/2014 03:03 PM, notbob wrote: I'm trying to learn python. I'm doing it via Zed Shaw's Learn Python the Hard Way. Sure enough, 16 lessons in and I've run aground. Is it OK for a painfully stupid ol' fart to ask painfully stupid noob questions, here? I'm a long time usenet fan and

  1   2   3   >