Dumb question. Your y is purely a function of x. So create an f(x) where
you want your y. It probably can even be anonymous inline. I mean your
return values of (x, y) would be (x, f(x)) ...
On Thu, Sep 1, 2022, 5:04 PM Chris Angelico wrote:
> On Fri, 2 Sept 2022 at 06:55, James Tsai wrote:
> >
Anton
There likely are such programs out there but are there universal agreements
on how to figure out when a new safe zone of code starts where error
testing can begin?
For example a file full of function definitions might find an error in
function 1 and try to find the end of that function and
Smallest code blocks first may be a more modern invention.
Some would argue for a rule related to efficiency of execution. When you
have multiple blocks as in an if-else or case statement with multiple
choices, that you order the most common cases first. Those shorten
execution more often than the
Since many languages allow placing multiple statements on one line or
spreading one over many lines, it seems that the number of lines in code
can be adjusted.
If I have a line like:
Alpha, beta, gamma, delta = 1, 2, 3, 4
Could that be rewritten as 4 or more lines?
I have seen programmers who
heads to puzzle
things out is harder than ordering longer items ...
On Sun, Oct 9, 2022, 12:30 PM Chris Angelico wrote:
> On Mon, 10 Oct 2022 at 03:22, Avi Gross wrote:
> >
> > Smallest code blocks first may be a more modern invention.
> >
> > Some would argue for a
and
parsing it. The loss in readability and so on probably is worse.
On Sun, Oct 9, 2022, 12:53 PM Chris Angelico wrote:
> On Mon, 10 Oct 2022 at 03:46, Avi Gross wrote:
> >
> > Chris, I was not arguing that at all.
>
> Maybe not intentionally, but you did lend a lot of we
:
>
>
> Op 9/10/2022 om 17:49 schreef Avi Gross:
> > My guess is that finding 100 errors might turn out to be misleading. If
> you
> > fix just the first, many others would go away.
>
> At this moment I would prefer a tool that reported 100 errors, which would
> allow me
pipeline.
When done, remove the lines with such entries or change the function
definition or something like that.
Objects used as pipelines do not do this as easily as you may need to add
methods ...
On Sun, Oct 9, 2022, 1:17 PM Peter J. Holzer wrote:
> On 2022-10-09 12:34:22 -0400, Avi Gr
:
> >
> >> Op 9/10/2022 om 17:49 schreef Avi Gross:
> >>> My guess is that finding 100 errors might turn out to be misleading.
> If you
> >>> fix just the first, many others would go away.
> >> At this moment I would prefer a tool that reported 100 er
Interesting idea, Anton.
I would be interested in hearing more detail on how it would work.
Although much of programming has been centered on the Latin alphabet and
especially English, that may change. I can imagine a customized compiler or
interpreter that uses key words in the local language in
There is no guarantee that argv is consulted earlier in the program than
other modules will use it for communication.
Consider a case where a program does look at argv but later wants to call
another program using some or all of the components of argv and now there
are added components there. That
[SPECULATION ALERT]
I found it interesting as people discussed how one gets the length of
something set up to follow the iterator protocol and especially anything
that is effectively infinite.
It is possible in python to set a value of "inf" using methods like this:
>>> x = float("inf")
>>> x
i
Cc: python-list@python.org
Subject: Re: dealing with infinite generators
On Mon, Dec 3, 2018 at 8:11 AM Avi Gross mailto:avigr...@verizon.net> > wrote:
[SPECULATION ALERT]
I found it interesting as people discussed how one gets the length of
something set up to follow the iterator pro
[[READERS DIGEST CONDENSED ANSWER: use int("string") ]]
Since we all agree python will not make notations like "05" work
indefinitely, and the need expressed is how to solve a symbolic puzzle (see
message below) then it makes sense to look at alternate representations.
I have a question first. Ho
digit', 'd': 2, 'e': 9}
{'a': 0, 'b': 8, 'c': 'any digit', 'd': 1, 'e': 9}
SOLVING FOR: b + d == e
matches found in batches of 10: 32
{'a': '0', 'b': 1, 'c': 'any di
Tim,
This may be a bit awkward.
I am not sure a question on the python list expects to get a one-liner, let
alone in an unrelated language like AWK. Unless you install other environments
like Cygwin, AWK does not tend to be available of platforms like Windows. Ditto
for PERL and other language
: Saturday, December 8, 2018 5:30 PM
To: python-list@python.org
Subject: Re: Why Python don't accept 03 as a number?
On 12/8/18 12:40 PM, Avi Gross wrote:
> You are solving for: ab + aa + cd == ce
Actually, an even quicker analysis for this particular problem is:
from the 10s digits, a + a
READERS DIGEST CONDENSED QUESTION: How expensive is eval("123 + 456 == 975")
versus other ways?
The discussion started by Jach has spread away from discussing how python deals
with numbers starting with leading zeroes such as "03". I note there are many
ID numbers like social security that have
SYNOPSIS: One way to solve math puzzle by brute force. (message sent earlier
disappeared)
Quick note. Jack started by asking why python does not like decimal numbers
with leading zeroes. When asked to explain, he said he was trying to solve word
problems using python. Someone mentioned probl
92087248958344081026378788915528519967248989338592027124423914083391771884524464968645052058218151010508471258285907685355807229880747677634789376
-Original Message-
From: Python-list On
Behalf Of Joe Pfeiffer
Sent: Wednesday, December 12, 2018 12:04 AM
To: python-list@python.org
Subject: Re: 03 digression by brute force
"
REAL SUBJECT: Analysis of alternate algorithms.
Peter & Jach and anyone interested,
As Peter said in his altered subject line, Jack changed directions from
tweaking an algorithm to trying something quite different.
Reminder of the problem.
Horizontal View:
SEND + MORE = MONEY
Vertical View:
-Original Message-
From: Avi Gross
Sent: Saturday, December 15, 2018 11:27 PM
To: 'Marc Lucke'
Subject: RE: clusters of numbers
Marc,
There are k-means implementations in python, R and other places. Most uses
would have two or more dimensions with a goal of specifyin
I appreciate the information by " BlindAnagram "
below. I myself claim to be from erehwon at times.
But to be clear, there are issues raised here where someone wants an easy
solution for the real world like "I have to build a webserver that searches a
database" and they would prefer an answer t
I have a serious question about what is already available out there in a
herpetologists dream pythonland.
SHORT VERSION: a way to automatically run multiple algorithms in parallel
and kill the rest when one returns an answer.
I know I can write this by hand. But it looks like the kind of t
Frank,
I am not commenting on your specific code, just asking a question.
If you have two tuples of the same size it does seem that python evaluates
them in the order you want just by doing something like this example I made
with a 2-tuple:
>>> (1, 2) > (2,1)
False
>>> (1, 2) > (1,1)
True
>>> (1
Frank,
Thanks for explaining.
It looks like you might want a shortcut compare done in an iterative or
recursive way that returns as soon as a discrepancy happens in the direction
you are comparing. If they are equal, you fall off the end.
A pythonic way is to use a loop as in:
>>> flag = True
>
There are quite a few places the new pythonic way of doing things requires
extra steps to get an iterator to expand into a list so Abdul-Rahmann
probably is right that there is no easy way to get a random key from a
standard dictionary. Other than the expected answers to make a customized
dictionar
likely to be from a
python dictionary.๐
-Original Message-
From: Python-list On
Behalf Of MRAB
Sent: Sunday, December 23, 2018 4:21 PM
To: python-list@python.org
Subject: Re: random choice from dictionary
On 2018-12-23 19:52, Avi Gross wrote:
> There are quite a few places the
into the mix as
variants of their methods.
I will stop here even if it means I have to kill myself. ๐
Avi
-Original Message-
From: Python-list On
Behalf Of Stefan Behnel
Sent: Monday, December 24, 2018 9:46 AM
To: python-list@python.org
Subject: Re: Fastest first
Avi Gross schrieb am 17
ืืืจื,
Your indentation did not make it through. So the first thing to guess is what
you are asking python to do.
It is often good to not just supply the code but point out what you are trying
to do as well as explain the small difference you made in your code that made
it work so we can zoom i
There have been several discussions about unexpected behavior when people
write programs within a class definition. Some suggest various ways around
the problem and that is fine although I bet new people will keep
encountering this issue.
I have some questions about what people want to do with
rhaps the problem does not
really need to be solved by me and I move on.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Thursday, December 27, 2018 5:11 PM
To: Python
Subject: Re: dangerous class neighborhood
On Fri, Dec 28, 2018 at 8:47 AM Avi Gross wrote:
>
private would serve no purpose.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Friday, December 28, 2018 12:08 AM
To: Python
Subject: Re: dangerous class neighborhood
On Fri, Dec 28, 2018 at 2:27 PM Avi Gross wrote:
>
> Sometimes when I post something I ge
used repeatedly in that context keeps only the
rightmost assignment. But there is an idiom of using just an underscore to mean
you donโt care about that and want something else whose name may be made
meaningful.
>>> _, _, LastName = ("John", "J.", "Doe")
&g
versus who knows what.
These can be subtle ideas for a newcomer, even for people who come from
languages that donโt have the distinctions. For that matter, there are ways to
say something is infinite which is not the same as saying the maximum value you
can store in N bits.
But I expres
Abdur-Rahman
I am sure various modules available have ready-made solutions and I see
others have replied to your question. The usual disclaimers apply. This is
an academic discussion and not a statement of the right or only way to do an
abstract task.
So just a thought. You seem interested in a G
Challenge: Can we name any computer language whose name really would suggest it
was a computer language?
Oh, if you say C is named as being the successor to some form of B, then R (as
you mentioned) is the successor by some form of backwards reasoning to S as it
started as not quite S or at lea
world advances, some growth is a good
idea. Bad analogy, but snakes do tend to shed their skin periodically as they
grow.
-Original Message-
From: Larry Martell
Sent: Wednesday, January 2, 2019 8:08 PM
To: Avi Gross
Cc: Python
Subject: Re: the python name
On Wed, Jan 2, 2019 at 8:04 P
Ok, this gives me a chance to say something actually python related.
Why did I mention Anaconda? Because python is also the name of a snake and
some people considered it appropriate to name their pet project that
includes python, as the name of another snake:
https://www.anaconda.com/
For people
On
Behalf Of DL Neil
Sent: Thursday, January 3, 2019 11:54 PM
To: 'Python'
Subject: Re: the python name
On 3/01/19 2:03 PM, Avi Gross wrote:
> Challenge: Can we name any computer language whose name really would
suggest it was a computer language?
>
> I think the name is
All this talk about language names makes me ask what can evolved languages like
python replace?
I mean clearly a language like ancient BASIC which had GOTO and GOSUB verbs may
not be anything worth considering.
But if there was a language that broke though as a functional programming
lan
ython-list
Sent: Friday, January 4, 2019 11:06 AM
To: Python
Cc: William R. Wing
Subject: Re: the python name
On 3/01/19 2:03 PM, Avi Gross wrote:
> Challenge: Can we name any computer language whose name really would suggest
> it was a computer language?
> I think the name is the least im
You can play mathematical reduction games and declare the only type of
variable needed is a memory location but who cares?
The reality is that well designed data structure can allow you to think
about a problem in a way that leads to easy solutions. True, you can store
something like an employee r
2019 13:22:03 Ian Kelly wrote:
> On Fri, Jan 4, 2019 at 10:59 AM Dennis Lee Bieber
wrote:
> > On Fri, 4 Jan 2019 01:12:42 -0500, "Avi Gross"
> >
> >
> > declaimed the following:
> > >language, Formula Translator? (I recall using the What For
>
Oops. They autocorrected the word piethon below so it makes no sense. I
meant a pie-eating-marathon or whatever.
-Original Message-
From: Python-list On
Behalf Of Avi Gross
Sent: Friday, January 4, 2019 6:55 PM
To: python-list@python.org
Subject: RE: the python name
Gene,
It is simple
From: Python-list On
Behalf Of Dennis Lee Bieber
Sent: Friday, January 4, 2019 1:17 PM
To: python-list@python.org
Subject: Re: the python name
On Fri, 4 Jan 2019 11:34:24 -0500, "Avi Gross"
declaimed the following:
>
>Although I used FORTRAN ages ago and it still seems to be in
n when viewed as
loops or exception handling. Heck, we now often hide loops.
-Original Message-
From: Python-list On
Behalf Of Dennis Lee Bieber
Sent: Saturday, January 5, 2019 1:46 PM
To: python-list@python.org
Subject: Re: the python name
On Fri, 4 Jan 2019 22:59:40 -0500, "Avi Gross&
IGRESSION.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Saturday, January 5, 2019 5:43 PM
To: Python
Subject: Re: the python name
On Sun, Jan 6, 2019 at 9:34 AM Avi Gross wrote:
> I recall an example from a version of mathematical LISP that I will
> rew
[Can we ever change the subject line?]
{REAL SUBJECT: degrees of compilation.}
Peter wrote:
"...
Hoever, this is the Python list and one of the advantages of Python is that we
don't have to compile our code. So we need a different excuse for fencing on
office chairs ;-).
..."
I understand what
n.org
Subject: Compilation (was: the python name)
On 2019-01-06 15:09:40 -0500, Avi Gross wrote:
> [Can we ever change the subject line?]
Feel free.
> {REAL SUBJECT: degrees of compilation.} Peter wrote:
>
> "... Hoever, this is the Python list and one of the advantages of
>
[HUMOR ALERT]
Others have given answers that are on topic so mine is not needed. I was
amused by the understandable spelling error about doing the unusual variant
of a Breath First Search when it is clear they meant Breadth.
But it may apply in this case. The Keven Bacon Game is a variation on
ca
Anton,
OVERVIEW: SET vs DICT
Some of us have less experience decoding Cyrillic error messages. The part we
can read suggests the program objected to the way a dictionary was being
updated.
ValueError: dictionary update sequence element #0 has length 35; 2 is required
(The Russian said someth
[This message comments on three different items being discussed and also on
how to find out what kind of help is actually requested and warranted.]
People don't usually provide enough context in their requests and I see
wildly different attempts to help. When some code is supplied along with
perha
f with Chris, or anyone here. The neighborhood is
safe again.
-Original Message-
From: Python-list On
Behalf Of Chris Angelico
Sent: Thursday, December 27, 2018 5:11 PM
To: Python
Subject: Re: dangerous class neighborhood
On Fri, Dec 28, 2018 at 8:47 AM Avi Gross wrote:
> Question 2: D
Madhavan,
Others have given you reasonable answers out of the ever so many many many
ways you can do what you asked. I offer a question to consider in case your
needs are different or you have not considered other more pythonic ways.
What do you want to do with your data and is this the best way
-Original Message-
From: Avi Gross
Sent: Saturday, January 12, 2019 8:26 PM
To: 'DL Neil'
Subject: RE: Python read text file columnwise
I am not sure what the big deal is here. If the data is consistently
formatted you can read in a string per line and use offsets as i
There is an old saying about getting what you paid for. Python can be free
but applications have costs.
Chris makes some valid points when saying there are existing solutions that
may be worth considering.
If someone wants to know about commercial products that do approximately
what they need and
[HUMOR for the ALERT]
The question that seems to come up too often about the python name is a
distraction. In particular, it is answered fairly prominently in many places
as just being a nonsensical name because a founder once liked a comedic
entity that chose an oddball name, so they did too.
Bu
I see messages like the following where someone is still asking how to do
something in some version of python 2.X.
I recall the days before the year 2000 with the Y2K scare when people
worried that legacy software might stop working or do horrible things once
the clock turned. It may even have bee
January 16, 2019 2:15 PM
To: Python
Subject: Re: Pythonic Y2K
On Thu, Jan 17, 2019 at 6:04 AM Avi Gross wrote:
>
> I see messages like the following where someone is still asking how to
> do something in some version of python 2.X.
>
> I recall the days before the year 2000 with the
To: python-list@python.org
Subject: Re: the python name
On Wed, 16 Jan 2019 13:46:29 -0500, "Avi Gross"
declaimed the following:
>[HUMOR for the ALERT]
>
>But as languages develop and evolve, sometimes a name change may be a
>decent idea. Perhaps version 4.0 should be r
ing in any one way, it is great.
If you want them to be able to read existing code and modify it, it can be a
headache especially when people abuse language features. And yes, I am an
abuser in that sense.
-Original Message-
From: Python-list On
Behalf Of Larry Martell
Sent: Wednesday, Jan
al Message-
From: Python-list On
Behalf Of DL Neil
Sent: Wednesday, January 16, 2019 11:04 PM
To: Python
Subject: Re: Pythonic Y2K
On 17/01/19 4:45 PM, Larry Martell wrote:
> On Wed, Jan 16, 2019 at 9:35 PM Avi Gross wrote:
>>
>> Chris,
>>
>> The comparison to Y2K
Message-
From: Python-list On
Behalf Of Gregory Ewing
Sent: Thursday, January 17, 2019 12:10 AM
To: python-list@python.org
Subject: Re: the python name
Avi Gross wrote:
> The question that seems to come up too often about the python name is
> a distraction. In particular, it is answere
ices. Heck, I have already used both together.
Their approaches can be maddeningly different and that opens up
opportunities.
-Original Message-
From: Python-list On
Behalf Of Avi Gross
Sent: Wednesday, January 16, 2019 9:49 PM
To: python-list@python.org
Subject: Guido (Sarducci)
Dennis,
I wish
at a disadvantage compared to
others who have gained experience with Python 3 if they ever have to change
employers.
--- Joseph S.
-Original Message-
From: Chris Angelico
Sent: Wednesday, January 16, 2019 2:15 PM
To: Python
Subject: Re: Pythonic Y2K
On Thu, Jan 17, 2019 at 6:04 AM Avi Gross
in 2000 B.C.
-Original Message-
From: Python-list On
Behalf Of Ian Kelly
Sent: Thursday, January 17, 2019 2:14 PM
To: Python
Subject: Re: Pythonic Y2K
On Wed, Jan 16, 2019 at 9:57 PM Avi Gross wrote:
>
> The forthcoming UNIX 2038 problem will, paradoxically happen on
> Janu
a DIFFERENT language than the
more modern python, fine.
-Original Message-
From: Python-list On
Behalf Of Michael Torrie
Sent: Friday, January 18, 2019 10:36 AM
To: python-list@python.org
Subject: Re: Pythonic Y2K
On 01/16/2019 12:02 PM, Avi Gross wrote:
> I recall the days before th
, 2019 10:47 AM
To: Python
Subject: Re: Pythonic Y2K
On Fri, Jan 18, 2019 at 10:43 AM Michael Torrie wrote:
>
> On 01/16/2019 12:02 PM, Avi Gross wrote:
> > I recall the days before the year 2000 with the Y2K scare when
> > people worried that legacy software might
Short question. Checking if a protocol is set up?
Many python improvements are changes to classes that implement a protocol.
There are things you can do to make your own classes work with the protocol
by setting various dunder variables like __iter__, __next__ and writing
appropriate ode including
See reply BELOW in sections marked by ==:
-Original Message-
From: DL Neil
Sent: Wednesday, January 23, 2019 7:39 PM
To: Avi Gross ; python-list@python.org
Subject: Re: checking protocols.
Avi
Haven't noticed an answer to this. Did I miss anything?
==REPLY ON no
I brought up a topic earlier and am now taking a different slant.
I am thinking of the wisdom of having a protocol on announcing what
protocols you implement.
Python has many protocols that are now part of the language and I suspect
many more will arise. Python already has a series of varia
I have chosen to stay out of the discussion as it clearly was a TEACHING
example where giving an ANSWER is not the point.
So I would like to add some thought without a detailed answer for the boring
way some are trying to steer an answer for. They are probably right that the
instructor wants th
I disagree, politely, Chris. The request is too BASIC and Radiator is best
done in R. I note especially how it has support for heat maps.
But as with Python, I recommend a recent version of 3.X, and at least
version 3.3.3 that came out in March 2017.
As for the python 2.7 radiator, it works bett
It is amazing to watch what happens when a fairly simple question is asked
to see how people answer.
In an effort not to ramble, I will summarize my thoughts. The student wanted
to know how to solve a problem using only what they already should know and
that specifically they should not use a meth
The discussion moved on to debating if an algorithm is O(N) or O(N**2).
For small amounts of text, on fast machines, it really is not worth worrying
about the cost of appending to the end of a growing string resulting in
multiple copies and lots of garbage collection. Many computer textbooks love
I may be missing something, but the focus seems to be only on the rightmost
digit. You can get that with
str(day)[-1]
or with
day % 10
Problem: print 1..31 using suffixes such as 1st, 2nd, 3rd, 4th ...
So your dictionary needs entries for "1" or 1 and "2" or "2" and of course 3
7;, 8:
'8th', 9: '9th', 10: '10th', 11: '11th', 12: '12th', 13: '13th', 14: '14th',
15: '15th', 16: '16th', 17: '17th', 18: '18th', 19: '19th', 20: '20th', 21:
'21st
The discussion strictly sets a limit of 31 for the largest number of days in
a month and asks for suffixes used to make ordinal numbers like 31st.
But in reality, you can go to 99th and beyond for other purposes albeit the
pattern for making 101 and on seems to repeat.
The last algorithm I wrote
Message asking about a fairly simple way to implement a switch in python as
per the ongoing discussion.
I wrote a function that might emulate a fairly simple general use of switch.
A function would take N+2 arguments of the form:
1: something to switch based on
2,3: something to match to
Comment at end:
-Original Message-
From: Python-list On
Behalf Of Bob van der Poel
Sent: Sunday, February 3, 2019 4:01 PM
To: DL Neil
Cc: Python
Subject: Re: Implement C's Switch in Python 3
I'm surprised that no one has yet addressed the year 1 problem.
Hopefully we're doing nu
[NOTE: message is a tad long as it discusses multiple possible solutions and
concerns including code.]
The original question was how to do some reasonable translation from
something like the "switch" statement in languages that have it, including C
and R. Other languages use their own variants
list On
Behalf Of Dan Sommers
Sent: Sunday, February 3, 2019 8:29 PM
To: python-list@python.org
Subject: Re: Switch function
On 2/3/19 5:40 PM, Avi Gross wrote:
> Bottom line, does anyone bother using anything like this? It is
> actually a bunch of hidden IF statements matched in order bu
Diego,
If your goal is to sum data by month, there are more general methods than
you making lists of starting and ending dates.
ONE way to consider in your case that is easy to understand is to add a
derived column/feature to your data such as the first 7 characters of the
date as perhaps a routi
The topic is how to deal with a python loop that may not be run if you want
something else to happen in that case. Multiple solutions are presented
along with this request:
> Is there another, more pythonic, approach to conditional (for/while)
> loop processing?
Has anyone considered looking at
Chris,
I would appreciate another pointer to the documentation explaining what was
done and why as I deleted the earlier discussion.
You ask:
> Aside from questions about the help format, what is actually lost by the
inability
> to pass those arguments by name?
I am not sure how python impleme
Bob,
>> tenserflow, pygame, scipy, and numby
> All of these are probably installable using pip. By the way did you mean
numpy?
> At a command prompt type pip install packagename.
While you are correcting the spelling of downloads as the downloader is
quite picky about exact spelling, please men
Without using regular expressions, if you just want to extract the word
"int" or "float" you can substring the results by converting what type says
to a string:
>>> a = 5
>>> str(type(a))[8:11]
'int'
>>> a=5.0
>>> str(type(a))[8:13]
'float'
Since the format and length vary, this may not meet you
then within that for the name like this:
>>> a = 5
>>> print(a.__class__.__name__)
int
>>> b = 5.0
>>> print(b.__class__.__name__)
float
-----Original Message-
From: Python-list On
Behalf Of Avi Gross
Sent: Sunday, February 10, 2019 5:43 PM
To: python-lis
ering or maybe
even implementing and in what ways it may not be compatible with present
functionality.
-Original Message-
From: Python-list On
Behalf Of Ian Kelly
Sent: Monday, February 11, 2019 1:46 AM
To: Python
Subject: Re: The slash "/" as used in the documentation
On Sun
speculate but
can picture problems.
I will talk about your C API question in another message.
-Original Message-
From: Python-list On
Behalf Of Ian Kelly
Sent: Monday, February 11, 2019 1:46 AM
To: Python
Subject: Re: The slash "/" as used in the documentation
On Sun, Feb 10, 20
ginal Message-
From: Python-list On
Behalf Of Ian Kelly
Sent: Monday, February 11, 2019 1:46 AM
To: Python
Subject: Re: The slash "/" as used in the documentation
On Sun, Feb 10, 2019 at 2:18 PM Avi Gross wrote:
> I am not sure how python implements some of the functionality it does
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
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
Other people have replied well enough with better ways to do this but I am
stuck on WHY this was seen as a way to do this at all.
The code was:
r = float('Nan')
while r==float('Nan'):
inp = input("Enter a number\n")
try:
r = float(inp)
except ValueError:
r = float
n)
>>> numpya == numpyb
False
>>> numpya is numpyb
True
-Original Message-
From: Python-list On
Behalf Of Grant Edwards
Sent: Thursday, February 14, 2019 6:15 PM
To: python-list@python.org
Subject: Re: FW: Why float('Nan') == float('Nan') is Fal
', 'fromhex',
'hex', 'imag', 'is_integer', 'real']
>>> id(numpy.nan)
57329632
This time that same address is reused:
>>> m = numpy.nan
>>> id(m)
57329632
>>> n = numpy.nan
>>> id(n)
57329632
So the nu
ot; went to "Nan"
So, indeed, the transcript lied. I will be more careful.
-Original Message-
From: Python-list On
Behalf Of Gregory Ewing
Sent: Friday, February 15, 2019 3:51 AM
To: python-list@python.org
Subject: Re: FW: Why float('Nan') == float('Nan
Just want to point out you can make any function into a generator by having
a yield statement like this:
>>> def previous(listing):
while listing: yield listing.pop()
>>> for num in previous([1,2,3,4]): print(num)
4
3
2
1
The above is an EXAMPLE, not a particularly great way to
This is not a complaint about python.
It is about the recent discussion about the concept and word "nan" as used
in python and elsewhere. As noted, the correct spelling in python is all
lower case as in "nan" with a minor exception that creating a nan using
float(string) allows any combination
1 - 100 of 414 matches
Mail list logo