Re: A limit to writing to a file from a loop?

2019-02-13 Thread Peter Otten
Steve wrote: > My program reads from a text file (A), modifies the data, and writes to > another file (B). This works until I reach about 300 writes and no more > lines are written to file (B). > > I had to create a Counter and increment it to 250 when it gets reset. > > Upon reset, I close the

Why float('Nan') == float('Nan') is False

2019-02-13 Thread ast
Hello >>> float('Nan') == float('Nan') False Why ? Regards -- https://mail.python.org/mailman/listinfo/python-list

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Dan Sommers
On 2/13/19 7:21 AM, ast wrote: Hello >>> float('Nan') == float('Nan') False Why ? Because the IEEE-754 Standard demands it, and people smarter than I worked on the IEEE-754 Standard. is a quick starting point for a deeper dive. -- https://mail.python.org/

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Grant Edwards
On 2019-02-13, ast wrote: > Hello > > >>> float('Nan') == float('Nan') > False If you think that's odd, how about this? >>> n = float('nan') >>> n nan >>> n is n True >>> n == n False >>> > Why ? IEEE says so. -- Grant Edwards grant.b.edwards

RE: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Avi Gross
I won't speak for the IEEE but NOT A NUMBER does not tell you what something IS. If "Hello, World!" is not a number as in an int or a float and we throw away the content and simply call it a NaN or something and then we notice that an object that is a list of fruits is also not a number so we call

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
ast writes: > Hello > float('Nan') == float('Nan') > False > > Why ? > > Regards Others have given the real answer -- IEEE says so, and the people who wrote the standard are smarter than me. All the same, this is my take on the reason for it: NaN is specifically a representation for "this

RE: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Schachner, Joseph
Because all comparisons with NAN return false, that's the spec. is NAN > 0? False. Is NAN< 0? False. Is NAN == 0? False. Is NAN == ? False. So: Is NAN == NAN? False. And one more: Is NAN < 1.0e18? False This makes some sense because NAN is Not A Number, so any comparison to a number fai

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Grant Edwards
On 2019-02-13, Schachner, Joseph wrote: > This makes some sense because NAN is Not A Number, so any comparison > to a number fails. Ah, but you now seem to be conflating "comparison fails" with "comparison has a boolean value of False". The alternative to (nan == nan) => False is probably not (

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:40 AM Schachner, Joseph wrote: > > Because all comparisons with NAN return false, that's the spec. Apart from !=, because it would be insane (I mean, even more insane than it is) to have nan == nan be false AND nan != nan. IEEE NAN has several purposes, including repres

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 6:55 AM Grant Edwards wrote: > > On 2019-02-13, Schachner, Joseph wrote: > > > This makes some sense because NAN is Not A Number, so any comparison > > to a number fails. > > Ah, but you now seem to be conflating "comparison fails" with > "comparison has a boolean value of

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Dan Sommers
On 2/13/19 1:53 PM, Grant Edwards wrote: Floating point is sort of the quantum mechanics of computer science. At first glance, it seems sort of weird. But after you work with it a while, it gets even worse. Yep! :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Test Bot
This definition of NaN is much better in mentally visualizing all the so called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be equal just as no 2 infinities would be equal. I believe in a hypothesis(of my own creation) that any arithmetic on a data type of NaN would be similar

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 7:12 AM Test Bot wrote: > > This definition of NaN is much better in mentally visualizing all the so > called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be > equal just as no 2 infinities would be equal. I believe in a hypothesis(of > my own creation)

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Marko Rauhamaa
"Avi Gross" : > A NaN is a bit like a black hole. Anything thrown in disappears and > that is about all we know about it. No two black holes are the same > even if they seem to have the same mass, spin and charge. All they > share is that we don't know what is in them. Then, how do you explain:

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Rob Gaddi
On 2/13/19 12:32 PM, Marko Rauhamaa wrote: "Avi Gross" : A NaN is a bit like a black hole. Anything thrown in disappears and that is about all we know about it. No two black holes are the same even if they seem to have the same mass, spin and charge. All they share is that we don't know what is

How do/can I generate a PKCS#12 file the cryptography module?

2019-02-13 Thread Travis Griggs
I’m using the cryptography module (https://cryptography.io/en/latest/) to try and generate some cert/key/identities. It's pretty easy using said module to generate the contents of .pem file for a private key: keyPEMBytes = privateKey.private_bytes( encoding=serialization.Encoding.P

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread אורי
אורי u...@speedy.net On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico wrote: > On Thu, Feb 14, 2019 at 7:12 AM Test Bot wrote: > > > > This definition of NaN is much better in mentally visualizing all the so > > called bizarreness of IEEE. This also makes intuitive that no 2 NaN will > be > > e

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
‪On Thu, Feb 14, 2019 at 8:24 AM ‫אורי‬‎ wrote:‬ > On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico wrote: >> >> Why would no two infinities be equal? In mathematics, there's one >> best-known infinity (aleph null, aka the number of counting numbers), >> and many many infinities are provably equal

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Avi Gross
I think we should realize that Nan and NA and so on are human constructs people Define in programming languages. Some have subdivisions as in not an int as compared to not a float. Python also has an Inf as well as a -Inf that are abstractions and not a real, so to speak. Number. Mathematics

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 9:07 AM Avi Gross wrote: > But that means that normal mathematics is warped. Well yes. Yes, it is. That's why people think "Alice's Adventures in Wonderland" is the result of a drug-induced dream - in actual fact, it's the result of the Dean of Mathematics telling stor

What's up with Activestate Python?

2019-02-13 Thread Grant Edwards
For many, many years I've always installed ActiveState's ActivePython Community edition when forced to use Windows. It has always included all of the "extra" libraries that I didn't wan't to install (or couldn't because I didn't have a C compiler for Windows). I recently decided to upgrade my Win

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread songbird
Chris Angelico wrote: > On Thu, Feb 14, 2019 at 7:12 AM Test Bot wrote: >> >> This definition of NaN is much better in mentally visualizing all the so >> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be >> equal just as no 2 infinities would be equal. I believe in a hypo

Best way to remove unused pip installed modules/module dependencies from a virtual env?

2019-02-13 Thread Malcolm Greene
Looking for advice on the best way to remove unused modules from a Python virtual environment. My setup is Python 3.6.6 running on macOS although I believe my use case is OS independent. Background: Long running project that, over the course of time, pip installed modules that are no longer used b

Re: Best way to remove unused pip installed modules/module dependencies from a virtual env?

2019-02-13 Thread Malcolm Greene
[Reformatted as original post got mangled] Looking for advice on the best way to remove unused modules from a Python virtual environment. My setup is Python 3.6.6 running on macOS although I believe my use case is OS independent. Background: Long running project that, over the course of time, p

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Chris Angelico
On Thu, Feb 14, 2019 at 11:01 AM songbird wrote: > all such proofs i have ever seen are based upon the > assumptions that there are infinite numbers of such > things like primes. I posted an abbreviated proof of that in a footnote. It's a proof by contradiction. First, assume that there are, in

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
songbird writes: > Chris Angelico wrote: >> On Thu, Feb 14, 2019 at 7:12 AM Test Bot wrote: >>> >>> This definition of NaN is much better in mentally visualizing all the so >>> called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be >>> equal just as no 2 infinities would be

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Joe Pfeiffer
u...@speedy.net writes: > There are more integers than odd numbers, and more odd numbers than prime > numbers. An infinite set may be a subset of another infinite set although > they may both have the same cardinality. Or in other words, the number of > elements in each set is not equal. One has m

Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread ast
Le 13/02/2019 à 14:21, ast a écrit : Hello >>> float('Nan') == float('Nan') False Why ? Regards Thank you for answers. If you wonder how I was trapped with it, here is the failing program. r = float('Nan') while r==float('Nan'): inp = input("Enter a number\n") try: r =