Re: Testing (sorry)
On 2/18/2024 6:09 PM, Grant Edwards via Python-list wrote: On 2024-02-18, Peter J. Holzer via Python-list wrote: [Replying to the list *and* Grant] On 2024-02-17 19:38:04 -0500, Grant Edwards via Python-list wrote: Today I noticed that nothing I've posted to python-list in past 3 weeks has shown up on the list. January 29th, AFAICS. And end of december before that. I don't know how to troubleshoot this other than sending test messages. Obviously, if this shows up on the list, then I've gotten it to work... This did show up and 3 other test messages with very similar text as well. Also there was a whole flurry of almost but not quite identical messages from you in the "nan" thread. Sorry about that. All of those were posted at various times throughout the day yesterday using two different accounts, two different mail servers, and three different methods for submitting the e-mails. I finally gave up and switched to using comp.lang.python via Usenet. Then, about 24 hours later, all those messages finally showed up. At one point about half way through that process yesterday, I unsusbscribed and then re-subscribed both e-mail addresses. I got confirmation and welcome messages on both accounts. Sending "help" requests to the list server produced the expected results. I enabled the sending of confirmation messages from the list server. But posts to the list still seemed to vanish into the ether while emails from both accounts reached other destinations without delay, During this process a number of posts from other users did appear in the list archive and at at _one_ of the two e-mail addresses which I had subscribed. But no sign of any of my posts. About 24 hours later, all of my posts (and the confirmation e-mails) all showed up in a burst at the same time on two different unrelated e-mail accounts. I still have no clue what was going on... Sometimes a post of mine will not show up for hours or even half a day. They are all addressed directly to the list. Sometimes my email provider sends me a notice that the message bounced. Those notices say that the address wasn't available when the transmission was tried. -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing (sorry)
I can't explain the delays, but will note that the gate-news program on the server runs every 5 minutes via cron. There are multiple moving parts in the overall system. You'll probably get a more useful answer from postmas...@python.org. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing (sorry)
On 19/02/24 12:09, Grant Edwards via Python-list wrote: ... But posts to the list still seemed to vanish into the ether while emails from both accounts reached other destinations without delay, During this process a number of posts from other users did appear in the list archive and at at _one_ of the two e-mail addresses which I had subscribed. But no sign of any of my posts. About 24 hours later, all of my posts (and the confirmation e-mails) all showed up in a burst at the same time on two different unrelated e-mail accounts. I still have no clue what was going on... Looking at the email-headers, there are sometimes considerable delays between messages submitted to the List-reflector, and their outward transmission (to me). Interestingly, there's something strange about the queuing. Instead of FIFO it seems some messages arrive ahead of others, ie out-of-sequence. (wonder if explained by submission via email or Usenet?) I've noted long delays too. Perhaps (also) to do with time-of-day? Always feel slightly embarrassed if 'repeat' an answer* that someone else had previously submitted, eg __new__ thread and @MRAB. However, if the reflector 'holds onto' the earlier message, then how should I/anyone know? * yes, repetition improves learning, slightly different words may help comprehension; but doubt I can express anything better than the aforementioned does/did/can. -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing (sorry)
On 2024-02-18, Peter J. Holzer via Python-list wrote: > [Replying to the list *and* Grant] > > On 2024-02-17 19:38:04 -0500, Grant Edwards via Python-list wrote: >> Today I noticed that nothing I've posted to python-list in past 3 >> weeks has shown up on the list. > > January 29th, AFAICS. And end of december before that. > >> I don't know how to troubleshoot this other than sending test >> messages. Obviously, if this shows up on the list, then I've gotten >> it to work... > > This did show up and 3 other test messages with very similar text > as well. > > Also there was a whole flurry of almost but not quite identical messages > from you in the "nan" thread. Sorry about that. All of those were posted at various times throughout the day yesterday using two different accounts, two different mail servers, and three different methods for submitting the e-mails. I finally gave up and switched to using comp.lang.python via Usenet. Then, about 24 hours later, all those messages finally showed up. At one point about half way through that process yesterday, I unsusbscribed and then re-subscribed both e-mail addresses. I got confirmation and welcome messages on both accounts. Sending "help" requests to the list server produced the expected results. I enabled the sending of confirmation messages from the list server. But posts to the list still seemed to vanish into the ether while emails from both accounts reached other destinations without delay, During this process a number of posts from other users did appear in the list archive and at at _one_ of the two e-mail addresses which I had subscribed. But no sign of any of my posts. About 24 hours later, all of my posts (and the confirmation e-mails) all showed up in a burst at the same time on two different unrelated e-mail accounts. I still have no clue what was going on... -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing (sorry)
We see you Peter AK On Sun, Feb 18, 2024 at 2:41 PM Peter J. Holzer via Python-list < python-list@python.org> wrote: > [Replying to the list *and* Grant] > > On 2024-02-17 19:38:04 -0500, Grant Edwards via Python-list wrote: > > Today I noticed that nothing I've posted to python-list in past 3 > > weeks has shown up on the list. > > January 29th, AFAICS. And end of december before that. > > > I don't know how to troubleshoot this other than sending test > > messages. Obviously, if this shows up on the list, then I've gotten > > it to work... > > This did show up and 3 other test messages with very similar text > as well. > > Also there was a whole flurry of almost but not quite identical messages > from you in the "nan" thread. > > hp > > -- >_ | Peter J. Holzer| Story must make more sense than reality. > |_|_) || > | | | h...@hjp.at |-- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 18/02/24 09:53, Grant Edwards via Python-list wrote: On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. [...] Battery Voltages and Currents Leisure Battery - 12.42 volts -0.52 Amps Starter Battery - nan voltsnan Amps What I would like is for those 'nan' strings to be just a '-' or something similar. The simplest thing is probably just a function writing it how you want it: def float_s(f): if isnan(f): return "-" return str(f) and then use eg: print(f'value is {float_s(value)}') or whatever fits your code. Except he's obviously using some sort of formatting to control the number of columns and decimal places, so 'str(f)' is not going to cut it. Is the basic floating point number formatting functionality seen when using f-strings or '%' operator part of the float type or is it part of the f-string and % operator? It's part of the PSL's string library: "Format Specification Mini-Language" https://docs.python.org/3/library/string.html#format-specification-mini-language Has the OP stated if we're talking 'Python' or numpy, pandas, ...? -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing (sorry)
[Replying to the list *and* Grant] On 2024-02-17 19:38:04 -0500, Grant Edwards via Python-list wrote: > Today I noticed that nothing I've posted to python-list in past 3 > weeks has shown up on the list. January 29th, AFAICS. And end of december before that. > I don't know how to troubleshoot this other than sending test > messages. Obviously, if this shows up on the list, then I've gotten > it to work... This did show up and 3 other test messages with very similar text as well. Also there was a whole flurry of almost but not quite identical messages from you in the "nan" thread. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On Mon, 19 Feb 2024 at 06:47, Grant Edwards via Python-list wrote: > I would be tempted to try monkey-patching the float class to override > the __format__ method. I have no idea what side effects that might > have, or if it's even used by the various formatting mechanisms, so > you might end up scraping bits off the walls... > You can try, but you'd have to do it in C - the float type is immutable in Python. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Matplotlib warning [error?] message
The latest[?] version of Matplotlib cannot show a figure. I get the annoying error message: "Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure" I'm using Spyder python 3.11 on Windows 11. What to do? -- Leif Svalgaard l...@leif.org -- https://mail.python.org/mailman/listinfo/python-list
Re: test-ignore
"Lawrence D'Oliveiro" wrote in message news:uqrik4$lrc1$1...@dont-email.me... On Sat, 17 Feb 2024 17:00:59 -0600, Science Researcher wrote: "Lawrence D'Oliveiro" wrote in message news:uqmbp3$3hsa6$1...@dont-email.me... If I remember correctly, I had to get the installation program from a third party site. I’m sure that was a perfectly trustworthy site, no doubt ... Comment: My moderately expensive computer virus program can be instructed to check the contents of downloaded EXE programs and other types of programs or ZIP files. It appears to do a fairly good job with that. But, you are correct. People should be careful regarding what they download. -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 16/02/2024 23.12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. This would then make it much easier to handle outputting values from sensors when not all sensors are present. So, for example, my battery monitoring program outputs:- Battery Voltages and Currents Leisure Battery - 12.42 volts -0.52 Amps Starter Battery - 12.34 volts -0.01 Amps If the starter battery sensor has failed, or is disconnected, I see:- Battery Voltages and Currents Leisure Battery - 12.42 volts -0.52 Amps Starter Battery - nan voltsnan Amps What I would like is for those 'nan' strings to be just a '-' or something similar. Obviously I can write conditional code to check for float('nan') values but is there a neater way with any sort of formatting string or other sort of cleverness? Uhm, I cannot see how to avoid conditional code. Somewhere, function, class, method, there should be an "if isnan(x)". You can hide that, but you cannot avoid, I suspect. bye, -- piergiorgio -- https://mail.python.org/mailman/listinfo/python-list
Proposed Python Computer Program - Feb. 17, 2024
PROPOSED PYTHON COMPUTER LANGUAGE PROGRAM - Posted on February 17, 2024 TOPICS Some Background Information Test Post Newsgroups Adding Posting Dates To Newsgroup Notes E-mail Address Other Internet Security Steps Personal Opinion Statements SOME BACKGROUND INFORMATION A fair amount of detail has been included with this Newsgroup post because now that I finally have my Newsgroup posting program running again, I am planning to soon start recommending that Python programmers around the world consider working on the creation of a very important python computer language program that I believe will be of great value to international disaster management efforts and to quite a few scientists around the world. The overall programming effort might best be run by university and government python programming personnel. But the computer program would have so many different uses that individual programmers would likely be able to make improvements and submit them for consideration by the university and government groups. A perl computer language version of the program has been running for years. A long time ago, code for an early version was formally copyrighted in the United States. Program code was also made available for free use under a GNU license. The version of perl that I am using processes computer program code in a very slow manner. The present perl program contains more than 13,000 line of code and has to generate png picture files by sending information to a gnuplot program. Compiled python programs would run much faster and be of greater value to scientists. Gnuplot, for example, would no longer be needed. I expect that once a python version of the program became available to scientists, the program would evolve with tremendous speed. It should have the ability to tell scientists how to make improvements to its own math routines. They would improve the program's data generation accuracy and its value. One of my specialty areas in science involves disaster management where I believe I am considered to be an "Expert." I have several degrees in the physical sciences. I do a fair amount of computer programming but would not be considered a python computer programming "Expert" or even a "Novice." So it would be difficult for me to translate the present perl and gnuplot routines to python. In the past, one programming problem resulted from the fact that I developed the original perl program with the help of a retired U.S. government computer programmer. He could work with gnuplot and TrueBasic but was unable to work with either perl or python. A number of compromises had to be made. One involved using gnuplot to generate picture files. TEST POST NEWSGROUPS Several response posts to my original test posts discussed sending them to some test Newsgroup before posting them to the comp.lang.python Newsgroup. I did post one or more of my original tests posts to the test.ignore Newsgroup. There were two problems that I was having was with my E-mail computer program - Windows Live Mail - that also creates my Newsgroup posts. First - It worked fine for E-mail after I installed it on my computer. But it would not work for Newsgroup posts. I called my E-mail server personnel about the problem. But they seemed to have no idea regarding what I was talking about and could not answer my questions. Second - my Newsgroup post program would not use the return E-mail address that I wanted it to use when it created Newsgroup posts. Solutions - The solutions for both problems were to just reset everything with my E-mail server and my E-mail and Newsgroup message creation program. Then the Newsgroup posting part of "Windows Live Mail" started working. ADDING POSTING DATES TO NEWSGROUP NOTES The contents of my Newsgroup posts are at times sent to people by E-mail or are posted to Internet forums. So, I usually add the posting date to my Newsgroup posts so that people receiving the E-mails or reading the forum posts know when the original Newsgroup message was posted. The E-mails etc. would just contain text information. People reading them would not be able to determine from the header information when the original Newsgroup note was posted. E-MAIL ADDRESS The response E-mail address attached to this Newsgroup post is a real E-mail address. It has a special form so that the address can be easily changed when spam robots start sending E-mails to that address. Over the years I have found that spam robots can create a variety of problems once they get hold of an E-mail address. Making a minor change in the E-mail address seems to take care of the problem. It appears that even a simple change can confuse most or all of the spam robots. For a while, they likely continue to send E-mails to an address that no longer exists and
Python Stampede Time? – Feb. 18, 2024
"Science Researcher" wrote in message news:z4acnqbo6mkf9kz4nz2dnzfqn_edn...@earthlink.com... PROPOSED PYTHON COMPUTER LANGUAGE PROGRAM - Posted on February 17, 2024 PYTHON STAMPEDE TIME ? – Posted on February 18, 2024 Before discussing this specific topic in detail I am going to mention another Internet security practice. That practice applies to this particular posting. WEB SITE ADDRESSES It can pose some risks for a person to post a note to any Newsgroup or for him or her to even circulate an E-mail letter that contains his or her exact Web site address. One of the reasons for this is the fact that many hackers around the world can probably gain access to files that contain Web site addresses. They can then change something in an address. When people click on that address they can then be fooled and transported to the hacker’s own Web site where there could be some malicious software. Generally, what I myself do is point people to major Internet search engines where they can find links to my personal Web site. I expect that it can be difficult for hackers to effectively trick major Internet search engines such as Yahoo or Google into providing people with inaccurate Web site addresses. The hackers might trick the search engines for short periods of time. But recovery for the search engines should be fairly rapid. PYTHON COMPUTER LANGUAGE PROGRAMMERS Over the years, I have worked with personnel involved with quite a few governments and organizations such as the United Nations. Some python Newsgroup readers might think that I am making up the following: Without any doubt and quite surprisingly, the most cooperative people whom I have ever encountered are the people who post notes to the python Newsgroup. My best guess is that they (some of you) do a certain amount of computer programming because it is simply interesting and fun. It is unlikely that anyone is paying you to post notes here. I hope that this spirit of cooperation will continue. Responses to this present post should indicate if that will remain the case. PYTHON STAMPEDE TIME ? What I discovered long ago is the fact that perhaps the best way to get other scientists around the world to do something, or even anything, is to create a “Science Stampede.” Most scientists like fame and fortune, especially the fame part. They like to publish scientific papers and see their publications get discussed in the international news. They DON’T like to feel like they are getting left behind in some area of science where they believe they might be experts. A “Science Stampede” involves circulating information that demonstrates that some important scientific discovery has been made. It proposes to scientists that their participation in some effort might get them some credit, or money, or both, with their employers or with international news service personnel. If the scientists believe that the circulated information is credible they are likely to try to get involved with the subject matter. They might ask their employers to pay them to work on the project being discussed. This sequence of events can quickly result in a “Science Stampede.” Everyone rushes to get a piece of the action. HOW TO CREATE A PYTHON COMPUTER PROGRAM STAMPEDE I am going to guess that the following should work. I hope that it will. MY WEB SITE Anyone who wants to visit my Web site can go to any major Internet search engine and type in the following line: earthquake research index.html Data.html My Earthquake Forecasting Web site address should be at or near the top of the returned list. If it is not, then try a different search engine. Near the top of the index.html Web page there is a link for one of my Web pages called “Humanitarian Projects.” If you click on that link you will find a discussion of a number of proposed python computer programming efforts. One is already running though I was not involved with the effort. It involves using python code to translate and compile programs written using other languages. One called PC BASIC was I believe created using that approach. Also near the top of the index.html Web page there is a link for one of my Web pages called “Energy Islands.” I believe that the “Energy Islands” discussed on my Web page represent a look into the future for some Renewable Energy projects. I am presently trying to get governments and scientific organization to take an interest in doing some research on those proposed “Inventions.” So far, I have never seen anything like them discussed anywhere. EARTHQUAKE RELATED PYTHON COMPUTER PROGRAMS My already existing perl language programs can do a number of things that are important for earthquake science. 1. They can generate data related to the locations of
Testing (sorry)
Today I noticed that nothing I've posted to python-list in the past 3 weeks has shown up on the list. I don't know how to troubleshoot this other than by sending test messages. Obviously, if this shows up on the list, then I'm making progress... [message 3] -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Testing (sorry)
Today I noticed that nothing I've posted to python-list in past 3 weeks has shown up on the list. I don't know how to troubleshoot this other than sending test messages. Obviously, if this shows up on the list, then I'm making progress. [message 4] -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Testing - 2 (sorry)
Today I noticed that nothing I've posted to python-list in past 3 weeks has shown up on the list. I don't know how to troubleshoot this other than sending test messages. Obviously, if this shows up on the list, then I've gotten it to work... -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Testing (sorry)
Today I noticed that nothing I've posted to python-list in past 3 weeks has shown up on the list. I don't know how to troubleshoot this other than sending test messages. Obviously, if this shows up on the list, then I've gotten it to work... -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 2024-02-16, Chris Green wrote: > I'm looking for a simple way to make NaN values output as something > like '-' or even just a space instead of the string 'nan'. I tried monkey-patching the __format__ method of float, but it's immutable, so that didnt' work. Is float.__format__ what's used by f-strings, the % operator, etc.? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Can one output something other than 'nan' for not a number values?
[I've been trying all afternoon to post via slrn, but nothing is showing up on the list. Forgive me if multiple posts eventually show up.] On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery - 12.42 volts -0.52 Amps >>Starter Battery - 12.34 volts -0.01 Amps > The simplest thing is probably just a function writing it how you > want it: > > def float_s(f): > if isnan(f): > return "-" > return str(f) Since he's obviously using one of the float formatting mechanisms to control the number of columsn and decimal places, I doubt str(f) will meet the need. I tried monkey-patching the float type's __format__ method, but it's immutable. Is float.__format__() what's used by f-strings, the '%' operator, etc.? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Can one output something other than 'nan' for not a number values?
[Posts via slrn and my GMail account aren't showing up, so I guess I'll try subscribing from a different e-mail address.] On 2024-02-17, Cameron Simpson via Python-list wrote: On 16Feb2024 22:12, Chris Green wrote: I'm looking for a simple way to make NaN values output as something like '-' or even just a space instead of the string 'nan'. [...] Battery Voltages and Currents Leisure Battery - 12.42 volts -0.52 Amps Starter Battery - 12.34 volts -0.01 Amps The simplest thing is probably just a function writing it how you want it: def float_s(f): if isnan(f): return "-" return str(f) Since he's obviously using one of the float formatting mechanisms to control the number of columsn and decimal places, I doubt str(f) will meet the need. I tried monkey-patching the float type's __format__ method, but it's immutable. Is float.__format__() what's used by f-strings, the '%' operator, etc.? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery - 12.42 volts -0.52 Amps >>Starter Battery - 12.34 volts -0.01 Amps > The simplest thing is probably just a function writing it how you > want it: > > def float_s(f): > if isnan(f): > return "-" > return str(f) Since he's obviously using one of the float formatting mechanisms to control the number of columsn and decimal places, I doubt str(f) will meet the need. I tried monkey-patching the float type's __format__ method, but it's immutable. Is float.__format__() what's used by f-strings, the '%' operator, etc.? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery - 12.42 volts -0.52 Amps >>Starter Battery - 12.34 volts -0.01 Amps > The simplest thing is probably just a function writing it how you > want it: > > def float_s(f): > if isnan(f): > return "-" > return str(f) Since he's obviously using one of the float formatting mechanisms to control the number of columsn and decimal places, I doubt str(f) will meet the need. I tried monkey-patching the float type's __format__ method, but it's immutable. Is float.__format__() what's used by f-strings, the '%' operator, etc.? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. [...] >> >>Battery Voltages and Currents >>Leisure Battery - 12.42 volts -0.52 Amps >>Starter Battery - nan voltsnan Amps >> >>What I would like is for those 'nan' strings to be just a '-' or >>something similar. > > The simplest thing is probably just a function writing it how you want > it: > > def float_s(f): > if isnan(f): > return "-" > return str(f) He's obviouisly using a formatting feature to control columns and decimal places, so I doubt that 'str(f)' is going to meet the need. I tried monkey-patching the __format__ method of the 'float' type, but it's immutable -- so that didn't work. Is float.__format__() what's used by f-strings, the % operator, etc.? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Yes - But it had to be specially installed - Feb. 17, 2024
"Lawrence D'Oliveiro" wrote in message news:uqmbp3$3hsa6$1...@dont-email.me... On Thu, 15 Feb 2024 15:15:58 -0600, E.D.G. wrote: X-Newsreader: Microsoft Windows Live Mail 15.4.3508.1109 Does that still exist? "Microsoft Windows Live Mail" did still exist when I installed it several years ago on my latest Windows Operating System. If I remember correctly, I had to get the installation program from a third party site. It might have been the Microsoft site. Or it might have been SourceForge.net. You would need to look around the Internet for valid copies of Windows Live Mail if you are interested in the program. Regards to all -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 2024-02-17, Cameron Simpson via Python-list wrote: > On 16Feb2024 22:12, Chris Green wrote: >>I'm looking for a simple way to make NaN values output as something >>like '-' or even just a space instead of the string 'nan'. >>[...] >> >>Battery Voltages and Currents >>Leisure Battery - 12.42 volts -0.52 Amps >>Starter Battery - nan voltsnan Amps >> >>What I would like is for those 'nan' strings to be just a '-' or >>something similar. > The simplest thing is probably just a function writing it how you want > it: > > def float_s(f): > if isnan(f): > return "-" > return str(f) > > and then use eg: > > print(f'value is {float_s(value)}') > > or whatever fits your code. Except he's obviously using some sort of formatting to control the number of columns and decimal places, so 'str(f)' is not going to cut it. Is the basic floating point number formatting functionality seen when using f-strings or '%' operator part of the float type or is it part of the f-string and % operator? -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Can one output something other than 'nan' for not a number values?
On 2024-02-16, Chris Green via Python-list wrote: > I'm looking for a simple way to make NaN values output as something > like '-' or even just a space instead of the string 'nan'. It would probably help if you told us how you're "outputting" them now (the Python feaatures/functions used, not the actual output format). Are you using f-strings, the % operator, str.format(), or ?? I would be tempted to try monkey-patching the float class to override the __format__ method. I have no idea what side effects that might have, or if it's even used by the various formatting mechanisms, so you might end up scraping bits off the walls... -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: Using __new__
On 2/17/24 19:24, dn via Python-list wrote: On 18/02/24 13:21, Jonathan Gossage wrote: - perhaps someone knows a better/proper way to do this? Suggested research: custom classes, ABCs, and meta-classes... Cure the old "what do you want to accomplish" question. If it's to channel access to a resource to a single place, many folks seem to advocate just putting that code in a module, and not trying to use a class for that - Python already treats modules as a form of singleton (if you squint a bit). It's not Java, after all, everything doesn't _have_ to be a class. I'd also second the idea of looking at metaclasses for an implementation. Most simpler class-based singleton approaches turn out not to be thread-safe... you can get closer to solving that with a metaclass with a lock taken in the dunder-call method. -- https://mail.python.org/mailman/listinfo/python-list