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

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 23:25:37 -0500, Roy Smith wrote: > I stopped paying attention to mathematicians when they tried to convince > me that the sum of all natural numbers is -1/12. I'm pretty sure they did not. Possibly a physicist may have tried to tell you that, but most mathematicians conside

Re: Geezer learns python

2014-03-04 Thread David
On 5 March 2014 10:03, 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 a

Struggling to create an extension wrapping a 3rd party dll

2014-03-04 Thread Christoff Kok
Hi, We are trying to wrap a 3rd party dll (written in C) to access it through python. The dll has a .lib .c and a .h file with it. We are accessing the dll through the .c file. Outisde of the extension (running as a console application), the code works without an issue. without the 3rd party d

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

2014-03-04 Thread Mark H. Harris
On Monday, March 3, 2014 7:46:38 PM UTC-6, Mark H. Harris wrote: > On Monday, March 3, 2014 5:34:30 AM UTC-6, Mark H. Harris wrote: > > > https://code.google.com/p/pythondecimallibrary/ > >https://pypi.python.org/pypi/pdeclib/0.3 Greetings, just a minor update here for version testing and po

Re: How security holes happen

2014-03-04 Thread Marko Rauhamaa
MRAB : > Into how many versions did Lisp split in its first 23 years? :-) I'm partial to Scheme, but I'll take any version. If you had tried Python 30 years ago, you'd give it up for any serious work because it would be so slow and consume so much memory. C++ virtual functions used to be avoided

Re: Reference

2014-03-04 Thread Ben Finney
Rustom Mody writes: > All I am saying is that 'is' should have (be!) a name that is not > philosophically grandiloquent bullshit but rather a name that more > accurately conveys 'machine-representation-equivalence' You haven't made either case. How is the simple abstraction of object identity c

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 11:53:21 AM UTC+5:30, Marko Rauhamaa wrote: > Rustom Mody : > > * ... which summarizes my objection in this thread: Python's 'is' > > leaks the machine abstraction. 'id' does it legitimately (somewhat), > > 'is' does it illegitimately > I agree that the Python data mod

Re: Reference

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 5:03 PM, Rustom Mody wrote: > I can say "'id' is just 'machine-id' is just address at some low level" And I can say that "id" returns a list of digits, but that doesn't make either statement true. The id() function returns a number which (a) never changes for any given obj

Re: Reference

2014-03-04 Thread Ben Finney
Rustom Mody writes: > I can say "'id' is just 'machine-id' is just address at some low > level" You could say that, but it's wrong. The only thing promised by “object identity” is that each object has it, and that it is different from the identity of every other object concurrently existing. “M

Re: Reference

2014-03-04 Thread alex23
On 5/03/2014 4:10 PM, Rustom Mody wrote: A python programmer who needs/wants to think of same/is in this sense should probably be using C or assembly Any programmer who is obsessing about some idea of philosophical purity should probably not be using Python. -- https://mail.python.org/mailma

Re: Reference

2014-03-04 Thread Ben Finney
Rustom Mody writes: > A python programmer who needs/wants to think of same/is in this sense > should probably be using C or assembly Please back up that bald assertion. How does the usefulness of the “object identity” abstraction oblige the programmer to not use Python? -- \ “Software pa

Re: Reference

2014-03-04 Thread Marko Rauhamaa
Rustom Mody : > * ... which summarizes my objection in this thread: Python's 'is' > leaks the machine abstraction. 'id' does it legitimately (somewhat), > 'is' does it illegitimately I agree that the Python data model can be exceedingly challenging to a beginner. However, I wouldn't throw the bab

Re: Reference

2014-03-04 Thread Ben Finney
Rustom Mody writes: > That python is a hll means that machine reprs are intended to be abstracted > away. 'is' fails to do that -- proof of that being the discrepancy between > is and == That's your proof? That is a non sequitur. Those two operators are *designed to be* different, to compare dif

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 11:31:04 AM UTC+5:30, alex23 wrote: > On 5/03/2014 3:47 PM, Rustom Mody wrote: > > That python is a hll means that machine reprs are intended to be abstracted > > away. 'is' fails to do that -- proof of that being the discrepancy between > > is and == > The "discrepancy

Re: Reference

2014-03-04 Thread alex23
On 5/03/2014 3:47 PM, Rustom Mody wrote: That python is a hll means that machine reprs are intended to be abstracted away. 'is' fails to do that -- proof of that being the discrepancy between is and == The "discrepancy" is because _they're fundamentally different_: >>> a = b = [1,2] >>

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: > > Python's 'is' leaks > > the machine abstraction. 'id' does it legitimately (somewhat), 'is' does > > it illegitimately > Can you elaborate on why id() is legitima

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 10:36:37 AM UTC+5:30, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: > > Python's 'is' leaks > > the machine abstraction. 'id' does it legitimately (somewhat), 'is' does > > it illegitimately > and then later in another post: > > "is"

Re: Working with the set of real numbers

2014-03-04 Thread Roy Smith
In article , Ben Finney wrote: > Roy Smith writes: > > > I stopped paying attention to mathematicians when they tried to convince > > me that the sum of all natural numbers is -1/12. > > I stopped paying attention to a particular person when they said “I > stopped paying attention to an en

Re: Reference

2014-03-04 Thread Steven D'Aprano
On Tue, 04 Mar 2014 19:36:38 -0800, Rustom Mody wrote: > Python's 'is' leaks > the machine abstraction. 'id' does it legitimately (somewhat), 'is' does > it illegitimately and then later in another post: > "is" in python leaks machine representations > into the otherwise clean HLL abstraction in

Re: Working with the set of real numbers

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 10:07:44 AM UTC+5:30, Ben Finney wrote: > Roy Smith writes: > > I stopped paying attention to mathematicians when they tried to convince > > me that the sum of all natural numbers is -1/12. > I stopped paying attention to a particular person when they said "I > stoppe

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 10:02:16 AM UTC+5:30, Ben Finney wrote: > Rustom Mody writes: > > * ... which summarizes my objection in this thread: > Your long post references many things. Which is the "which" to which you > refer? What is it you're referring to that summarises your position? Text

Re: Working with the set of real numbers

2014-03-04 Thread Ben Finney
Roy Smith writes: > I stopped paying attention to mathematicians when they tried to convince > me that the sum of all natural numbers is -1/12. I stopped paying attention to a particular person when they said “I stopped paying attention to an entire field of study because one position expressed

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 9:38:58 AM UTC+5:30, Ian wrote: > On Tue, Mar 4, 2014 at 8:36 PM, Rustom Mody wrote: > > * ... which summarizes my objection in this thread: Python's 'is' leaks the > > machine abstraction. 'id' does it legitimately (somewhat), > > 'is' does it illegitimately > Well, si

Re: Reference

2014-03-04 Thread Ben Finney
Rustom Mody writes: > * ... which summarizes my objection in this thread: Your long post references many things. Which is the “which” to which you refer? What is it you're referring to that summarises your position? > Python's 'is' leaks the machine abstraction. No, it does not. The ‘is’ opera

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

2014-03-04 Thread Roy Smith
In article , Rustom Mody wrote: > I cannot find the exact quote so from memory Weyl says something to this > effect: > > Cantor's diagonalization PROOF is not in question. > Its CONCLUSION very much is. > The classical/platonic mathematician (subject to wooly thinking) concludes > that > the

Re: How security holes happen

2014-03-04 Thread Gene Heskett
On Tuesday 04 March 2014 23:17:40 Andrew Cooper did opine: > On 03/03/2014 22:19, Cameron Simpson wrote: > > On 03Mar2014 09:17, Neal Becker wrote: > >> Charles R Harris Wrote in message: > >> Imo the lesson here is never write in low level c. Use modern > >> > >> languages with well designed

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

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 9:11:13 AM UTC+5:30, Steven D'Aprano wrote: > On Wed, 05 Mar 2014 02:15:14 +, Albert van der Horst wrote: > > Adding cf's adds all computable numbers in infinite precision. However > > that is not even a drop in the ocean, as the computable numbers have > > measure

Re: Proper conversion of timestamp

2014-03-04 Thread MRAB
On 2014-03-05 02:33, Ben Finney wrote: Igor Korot writes: On Tue, Mar 4, 2014 at 4:42 PM, MRAB wrote: >> But this particular question is easy. >> >> What I have is a timestamp which reads: 1289410678L. >> > That's an integer. It looks like the timestamp is a whole number of > seconds, so the

Re: Proper conversion of timestamp

2014-03-04 Thread Gregory Ewing
Igor Korot wrote: What I have is a timestamp which reads: 1289410678L. Trying to convert this into the datetime object in Python using: import datetime datetime.datetime.fromtimestamp( stamp ) produces the error: timestamp out of range for platform localtime()/gmtime() function. Divide the

Re: How security holes happen

2014-03-04 Thread MRAB
On 2014-03-05 01:57, Roy Smith wrote: In article , Dennis Lee Bieber wrote: On Wed, 05 Mar 2014 00:48:40 +0200, Marko Rauhamaa declaimed the following: >Ethan Furman : > >> Okay, that looks totally cool. Maybe I'll finally get a handle on >> LISP! :) > >Lisp is conceptually simpler than Py

Re: Reference

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 8:36 PM, Rustom Mody wrote: > * ... which summarizes my objection in this thread: Python's 'is' leaks the > machine abstraction. 'id' does it legitimately (somewhat), > 'is' does it illegitimately Well, since "if x == None" is buggy as a test for sentinel values, that means

Re: Geezer learns python

2014-03-04 Thread Mark H. Harris
On Tuesday, March 4, 2014 5:03:13 PM UTC-6, notbob wrote: {snip} hi notbob, Get a good book on python3 programming {Barnes and Noble, Amazon} and please, start with python (3). Great book: & fabulous tutorial: Summerfield, Mark. Programming in Python 3: A Complete Introduction to the Py

Re: Origin of 'self'

2014-03-04 Thread MRAB
On 2014-03-05 03:45, Rustom Mody wrote: On Tuesday, March 4, 2014 6:17:09 PM UTC+5:30, MRAB wrote: On 2014-03-04 02:09, Dennis Lee Bieber wrote: > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez declaimed: >> I understand that in an object method the first argument in the >> object

Re: Origin of 'self'

2014-03-04 Thread Rustom Mody
On Tuesday, March 4, 2014 6:17:09 PM UTC+5:30, MRAB wrote: > On 2014-03-04 02:09, Dennis Lee Bieber wrote: > > On Sun, 2 Mar 2014 22:16:31 -0800 (PST), Westley Martínez declaimed: > >> I understand that in an object method the first argument in the > >> object itself, called self. However, it does

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

2014-03-04 Thread Steven D'Aprano
On Wed, 05 Mar 2014 02:15:14 +, Albert van der Horst wrote: > Adding cf's adds all computable numbers in infinite precision. However > that is not even a drop in the ocean, as the computable numbers have > measure zero. On the other hand, it's not really clear that the non-computable numbers

Re: Reference

2014-03-04 Thread Rustom Mody
On Wednesday, March 5, 2014 7:39:17 AM UTC+5:30, Roy Smith wrote: > "Rhodri James" wrote: > > wrote: > > > Code should look like its intent. Warping it around performance is > > > hardly ever worthwhile. > > That depends. In Python, I'd agree with you; if I'm worrying about > > performance in P

Re: 3.4rc2 and pip on windows

2014-03-04 Thread Mark Lawrence
On 04/03/2014 05:32, Terry Reedy wrote: On 3/3/2014 2:47 PM, Mark Lawrence wrote: On 03/03/2014 00:07, Terry Reedy wrote: On 3/2/2014 6:55 PM, Mark Lawrence wrote: Trying to install pyttsx, it doesn't strike me as very clever that, as seen below, you get "Successfully installed pyttsx" despite

Re: Working with the set of real numbers

2014-03-04 Thread Albert van der Horst
In article <87fvnm7q1n@elektro.pacujo.net>, Marko Rauhamaa wrote: >Chris Angelico : > >> On Fri, Feb 14, 2014 at 1:00 AM, Marko Rauhamaa wrote: >>> Well, if your idealized, infinite, digital computer had ℵ₁ bytes of RAM >>> and ran at ℵ₁ hertz and Python supported transfinite iterati

Re: Proper conversion of timestamp

2014-03-04 Thread Mark Lawrence
On 05/03/2014 02:13, Igor Korot wrote: Hi, Mark, On Tue, Mar 4, 2014 at 2:46 PM, Mark Lawrence wrote: 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? What I meant to say is: it is easy

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

2014-03-04 Thread Albert van der Horst
In article , Chris Angelico wrote: >On Tue, Mar 4, 2014 at 1:45 PM, Albert van der Horst > wrote: >>>No, the Python built-in float type works with a subset of real numbers: >> >> To be more precise: a subset of the rational numbers, those with a >> denominator >> that is a power of two. > >And n

Re: Proper conversion of timestamp

2014-03-04 Thread Ben Finney
Igor Korot writes: > On Tue, Mar 4, 2014 at 4:42 PM, MRAB wrote: > >> But this particular question is easy. > >> > >> What I have is a timestamp which reads: 1289410678L. > >> > > That's an integer. It looks like the timestamp is a whole number of > > seconds, so the number of milliseconds is 0.

Re: How do I process this?

2014-03-04 Thread alex23
On 4/03/2014 2:03 PM, Igor Korot wrote: Hi, ALL, I have a csv file which depending on how it was produced gives 2 different strings as shown in the example below (test1 and test2). I am only interested in the first field in test1 and obviously in the whole string of test2. >>> test1 = "a" >

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

2014-03-04 Thread Mark H. Harris
On Tuesday, March 4, 2014 3:35:48 PM UTC-6, Stefan Krah wrote: > http://www.bytereef.org/mpdecimal/quickstart.html#factorial-in-pure-python > Be sure to set MAX_EMAX and MIN_EMIN, that's missing in the example. > http://www.bytereef.org/mpdecimal/benchmarks.html#arbitrary-precision-libraries > S

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

2014-03-04 Thread Albert van der Horst
In article , Ian Kelly wrote: >On Mon, Mar 3, 2014 at 11:35 PM, Chris Angelico 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 infin

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
MRAB, On Tue, Mar 4, 2014 at 4:42 PM, MRAB wrote: > On 2014-03-04 21:55, Igor Korot wrote: >> >> Hi, Mark, >> >> >> On Tue, Mar 4, 2014 at 1:44 PM, Mark Lawrence > > wrote: >> >> On 04/03/2014 20:57, Igor Korot wrote: >> >> Hi, ALL, >> I'm getti

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
Hi, Mark, On Tue, Mar 4, 2014 at 2:46 PM, Mark Lawrence wrote: > 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? What I meant to say is: it is easy for all you people and it is de

Re: Reference

2014-03-04 Thread Roy Smith
In article , "Rhodri James" wrote: > On Tue, 04 Mar 2014 05:24:03 -, Chris Angelico > wrote: > > > Code should look like its intent. Warping it around performance is > > hardly ever worthwhile. > > That depends. In Python, I'd agree with you; if I'm worrying about > performance in Py

Re: How security holes happen

2014-03-04 Thread Roy Smith
In article , Dennis Lee Bieber wrote: > On Wed, 05 Mar 2014 00:48:40 +0200, Marko Rauhamaa > declaimed the following: > > >Ethan Furman : > > > >> Okay, that looks totally cool. Maybe I'll finally get a handle on > >> LISP! :) > > > >Lisp is conceptually simpler than Python, but awe-inspiring.

Re: How to create an instance of a python class from C++

2014-03-04 Thread Ian Kelly
On Tue, Mar 4, 2014 at 5:14 PM, Bill wrote: > Hello: > > I can't figure out how to create an instance > of a python class from 'C++': > > ( I am relatively new to Python so excuse some of > the following. ) > > In a .py file I create an ABC and then specialize it: Why are you creating an ABC?

Re: Reference

2014-03-04 Thread Rhodri James
On Tue, 04 Mar 2014 05:24:03 -, Chris Angelico wrote: Code should look like its intent. Warping it around performance is hardly ever worthwhile. That depends. In Python, I'd agree with you; if I'm worrying about performance in Python, I'm worrying at the level of the algorithms I'm

Re: How security holes happen

2014-03-04 Thread Andrew Cooper
On 03/03/2014 22:19, Cameron Simpson wrote: > On 03Mar2014 09:17, Neal Becker wrote: >> Charles R Harris Wrote in message: >>> >> >> Imo the lesson here is never write in low level c. Use modern >> languages with well designed exception handling. > > What, and rely on someone else's low level

Re: Proper conversion of timestamp

2014-03-04 Thread MRAB
On 2014-03-04 21:55, Igor Korot wrote: Hi, Mark, On Tue, Mar 4, 2014 at 1:44 PM, Mark Lawrence mailto:breamore...@yahoo.co.uk>> wrote: On 04/03/2014 20:57, Igor Korot wrote: Hi, ALL, I'm getting this: timestamp out of range for platform localtime()/gmtime() functi

Re: Reference

2014-03-04 Thread Rhodri James
On Tue, 04 Mar 2014 11:48:46 -, Steven D'Aprano wrote: 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* As any gamer will tell you, dice are not random number generators. T

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> Python doesn't have anonymous inner classes, but it has named inner >> classes, and that's quite sufficient. > > I would say it's Python's closures that make up for not having Java's > inner classes. > > Or to put it another way, inner classes are Java's

How to create an instance of a python class from C++

2014-03-04 Thread Bill
Hello: I can't figure out how to create an instance of a python class from 'C++': ( I am relatively new to Python so excuse some of the following. ) In a .py file I create an ABC and then specialize it: from MyMod import * from abc import ABCMeta, abstractmethod # Declare an abst

Re: find and replace string in binary file

2014-03-04 Thread emile
On 03/04/2014 02:44 PM, Chris Angelico wrote: 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 st

Re: How security holes happen

2014-03-04 Thread Cameron Simpson
On 05Mar2014 09:57, Chris Angelico wrote: > On Wed, Mar 5, 2014 at 9:48 AM, Marko Rauhamaa 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 achi

Re: Functional programming

2014-03-04 Thread Gregory Ewing
Marko Rauhamaa wrote: Python doesn't have anonymous inner classes, but it has named inner classes, and that's quite sufficient. I would say it's Python's closures that make up for not having Java's inner classes. Or to put it another way, inner classes are Java's kludgy way of working around a

Re: How security holes happen

2014-03-04 Thread Mark Lawrence
On 04/03/2014 23:22, Chris Angelico wrote: On Wed, Mar 5, 2014 at 10:16 AM, Mark Lawrence wrote: Man, imagine what you could do with a Unicode version of Whitespace? Yes, but how do we pursuade the Python core devs to give us a decent implementation? Let's face it, according to our resident

Re: Geezer learns python

2014-03-04 Thread Mark Lawrence
On 04/03/2014 23:03, 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 prefer i

Re: How security holes happen

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 10:16 AM, Mark Lawrence wrote: >> Man, imagine what you could do with a Unicode version of Whitespace? >> > > Yes, but how do we pursuade the Python core devs to give us a decent > implementation? Let's face it, according to our resident unicode expert, > they can't get any

Re: How security holes happen

2014-03-04 Thread Mark Lawrence
On 04/03/2014 22:59, Roy Smith wrote: In article , Chris Angelico wrote: On Wed, Mar 5, 2014 at 9:48 AM, Marko Rauhamaa 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 fin

Re: Working with the set of real numbers

2014-03-04 Thread Dave Angel
Oscar Benjamin Wrote in message: > On 4 March 2014 21:18, Chris Angelico wrote: > > > It does not take O(n*n) time. This is Newton iteration and for > well-behaved problems such as this it generates more than n digits > after n iterations. I modified my code to show the error (x**2 - y) at > ea

Re: Geezer learns python

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 10:03 AM, 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 usen

Re: Geezer learns python

2014-03-04 Thread Michael Torrie
On 03/04/2014 04: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

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 prefe

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 man

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 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 represented expo

Re: How security holes happen

2014-03-04 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, Mar 5, 2014 at 9:48 AM, Marko Rauhamaa 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

Re: How security holes happen

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 9:48 AM, Marko Rauhamaa 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, but simply edi

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 22:18, Chris Angelico wrote: > On Wed, Mar 5, 2014 at 9:02 AM, Oscar Benjamin > wrote: >> On 4 March 2014 21:18, Chris Angelico wrote: >>> On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin >>> wrote: >>> >>> epsilon = 0.0001 >>> def sqrt(n): >>> guess1, guess2 = 1, n >>> wh

Re: How security holes happen

2014-03-04 Thread Marko Rauhamaa
Ethan Furman : > 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 http://en.wikipedia.org/wiki/Combinato

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 f

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

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 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 wr

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~ -- https://mail.python.org/mai

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 wrote: > On 4 March 2014 21:18, Chris Angelico wrote: >> On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin >> 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

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 21:05, Marko Rauhamaa wrote: > Oscar Benjamin : > >> 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

Re: Proper conversion of timestamp

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:55 AM, Igor Korot 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 thread, two people

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 21:18, Chris Angelico wrote: > On Wed, Mar 5, 2014 at 7:55 AM, Oscar Benjamin > 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 m

Re: Reference

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:53 AM, Alexander Blinne 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. Until I p

Re: Proper conversion of timestamp

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:46 AM, Igor Korot 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 dividing by 1000

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
Hi, Mark, On Tue, Mar 4, 2014 at 1:44 PM, Mark Lawrence wrote: > 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.

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
Mark, On Tue, Mar 4, 2014 at 1:45 PM, Mark Lawrence wrote: > 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 m

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 no

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:43 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> 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

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: http://stack

Re: Proper conversion of timestamp

2014-03-04 Thread Igor Korot
MRAB, On Tue, Mar 4, 2014 at 1:38 PM, 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 fi

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Chris Angelico : > 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, STL and Boost

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: http://stackoverflow.com/questions/12458595/co

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 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: http://www.bytereef.org/

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: http://stackoverflow.com/questions/12458595/co

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 8:21 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> 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

Re: Functional programming

2014-03-04 Thread Marko Rauhamaa
Chris Angelico : > 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. An ergonomic di

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 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 digits N becomes lar

Re: Working with the set of real numbers

2014-03-04 Thread Marko Rauhamaa
Oscar Benjamin : > 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, prec=1000): > ''

Re: Functional programming

2014-03-04 Thread Chris Angelico
On Wed, Mar 5, 2014 at 7:50 AM, Marko Rauhamaa 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 limitatio

Re: Working with the set of real numbers

2014-03-04 Thread Oscar Benjamin
On 4 March 2014 19:58, Chris Angelico wrote: > On Wed, Mar 5, 2014 at 6:49 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> 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

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: Functional programming

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

  1   2   >