Re: Subject: problem activating python

2022-12-17 Thread Michael Torrie
On 12/17/22 15:45, Anne wrote: >I tried several times to install and use python for youtube views with Tor >using Youtube tutorials but I keep getting error after error. Please help >me. >regards Dimpho Given the lack of any information in your post, I can only assume you're trying

Re: Single line if statement with a continue

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 10:59, wrote: > > If a compiler or interpreter HAPPILY (as happy as machines/code get) compiles > or interprets your code without errors every time you use it a certain way, > then it is not wrong to use it. Of course if it subject to change or already > deprecated, ... >

Re: Single line if statement with a continue

2022-12-17 Thread Thomas Passin
>if 5 > 3: a = a * 3 > b = b * 3 That would be a fairly weird construction, neither one thing nor another. But still, if you really want it that way, this is legal Python: a = 2; b = 10 if 5 > 3: a = a * 3;\ b = b * 3 print(a, b) # 6 30 On 12/17/2022 6:57 PM, avi.e.gr...@

RE: Single line if statement with a continue

2022-12-17 Thread avi.e.gross
I happen to be of two schools here. Is something sort of taboo when using something like a computer language to write a program? What if another language tells you to do it a different way or sort of the opposite? Is it based on the details of the language and implementation or the prejudices o

Re: Subject: problem activating python

2022-12-17 Thread Mats Wichmann
On 12/17/22 15:45, Anne wrote: I tried several times to install and use python for youtube views with Tor using Youtube tutorials but I keep getting error after error. Please help me. regards Dimpho Folks around here tend to be pretty helpful. But only if you describe the prob

RE: String to Float, without introducing errors

2022-12-17 Thread avi.e.gross
As often seems to happen, someone asks something that may not be fully clear and others chime in and extend the question. Was the original question how to read in a ingle column of numbers from a file that are all numeric and NOT integers and be able to use them? If so, the answer was quite tri

Re: String to Float, without introducing errors

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 09:46, Stefan Ram wrote: > > Grant Edwards writes: > >Yes, fixed point (or decimal) is a better fit for what he's doing. but > >I suspect that floating point would be a better fit for the problem > >he's trying to solve. > > I'd like to predict that within the next ten po

Subject: problem activating python

2022-12-17 Thread Anne
I tried several times to install and use python for youtube views with Tor using Youtube tutorials but I keep getting error after error. Please help me. regards Dimpho         -- https://mail.python.org/mailman/listinfo/python-list

Re: Single line if statement with a continue

2022-12-17 Thread dn
On 16/12/2022 02.30, Rob Cliffe via Python-list wrote: On 15/12/2022 04:35, Chris Angelico wrote: On Thu, 15 Dec 2022 at 14:41, Aaron P wrote: I occasionally run across something like: for idx, thing in enumerate(things): if idx == 103: continue do_something_with(thing) It

Re: String to Float, without introducing errors

2022-12-17 Thread dn
On 18/12/2022 01.39, Peter J. Holzer wrote: On 2022-12-17 12:51:17 +0100, Paul St George wrote: I have a large/long array of numbers in an external file. The numbers look like this: -64550.727 -64511.489 -64393.637 [...] When I bring the numbers into my code, they are Strings. To use the num

Re: String to Float, without introducing errors

2022-12-17 Thread Thomas Passin
On 12/17/2022 3:45 PM, Paul St George wrote: Thanks to all! It was the rounding rounding error that I needed to avoid (as Peter J. Holzer suggested). The use of decimal solved it and just in time. I was about to truncate the number, get each of the characters from the string mantissa, and then

Re: String to Float, without introducing errors

2022-12-17 Thread Peter J. Holzer
On 2022-12-17 21:45:06 +0100, Paul St George wrote: > It was the rounding rounding error that I needed to avoid (as Peter J. > Holzer suggested). The use of decimal solved it and just in time. I > was about to truncate the number, get each of the characters from the > string mantissa, and then do s

Re: String to Float, without introducing errors

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 08:22, Grant Edwards wrote: > > On 2022-12-17, Chris Angelico wrote: > > >> It was the rounding rounding error that I needed to avoid (as Peter > >> J. Holzer suggested). The use of decimal solved it and just in > >> time. I was about to truncate the number, get each of the

Re: String to Float, without introducing errors

2022-12-17 Thread Grant Edwards
On 2022-12-17, Chris Angelico wrote: >> It was the rounding rounding error that I needed to avoid (as Peter >> J. Holzer suggested). The use of decimal solved it and just in >> time. I was about to truncate the number, get each of the >> characters from the string mantissa, and then do something

Re: String to Float, without introducing errors

2022-12-17 Thread Chris Angelico
On Sun, 18 Dec 2022 at 07:46, Paul St George wrote: > > Thanks to all! > It was the rounding rounding error that I needed to avoid (as Peter J. Holzer > suggested). The use of decimal solved it and just in time. I was about to > truncate the number, get each of the characters from the string man

Re: String to Float, without introducing errors

2022-12-17 Thread Paul St George
Thanks to all! It was the rounding rounding error that I needed to avoid (as Peter J. Holzer suggested). The use of decimal solved it and just in time. I was about to truncate the number, get each of the characters from the string mantissa, and then do something like this: 64550.727 64550 + (7

Re: Single line if statement with a continue

2022-12-17 Thread Abdullah Nafees
Just wanted to say that a silent reader like me learnt more about PEP-8 solely from this thread than my mentor at work or any other course I have taken earlier this year. Thank you so much. On Sun, 18 Dec 2022, 00:16 Rob Cliffe via Python-list, < python-list@python.org> wrote: > > > On 15/12/2022

Re: Keeping a list of records with named fields that can be updated

2022-12-17 Thread Albert-Jan Roskam
On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote: >>> from collections import namedtuple >>> Row = namedtuple("Row", "foo bar baz") >>> row = Row(1, 2, 3) >>> row._replace(bar=42) Row(foo=1, bar=42, baz=3) Ahh, I always thought these are undocumen

Re: Top level of a recursive function

2022-12-17 Thread Rob Cliffe via Python-list
On 14/12/2022 13:49, Stefan Ram wrote: I also found an example similar to what was discussed here in pypy's library file "...\Lib\_tkinter\__init__.py": |def _flatten(item): |def _flatten1(output, item, depth): |if depth > 1000: |raise ValueError("nesting too deep i

Re: Single line if statement with a continue

2022-12-17 Thread Rob Cliffe via Python-list
On 15/12/2022 04:35, Chris Angelico wrote: On Thu, 15 Dec 2022 at 14:41, Aaron P wrote: I occasionally run across something like: for idx, thing in enumerate(things): if idx == 103: continue do_something_with(thing) It seems more succinct and cleaner to use: if idx == 10

Re: String to Float, without introducing errors

2022-12-17 Thread Thomas Passin
On 12/17/2022 1:41 PM, Mats Wichmann wrote: On 12/17/22 07:15, Thomas Passin wrote: You have strings, and you want to end up with numbers.  The numbers are not integers.  Other responders have gone directly to whether you should use float or decimal as the conversion, but that is a secondary m

Re: String to Float, without introducing errors

2022-12-17 Thread Mats Wichmann
On 12/17/22 07:15, Thomas Passin wrote: You have strings, and you want to end up with numbers.  The numbers are not integers.  Other responders have gone directly to whether you should use float or decimal as the conversion, but that is a secondary matter. If you have integers, convert with i

Re: String to Float, without introducing errors

2022-12-17 Thread Thomas Passin
You have strings, and you want to end up with numbers. The numbers are not integers. Other responders have gone directly to whether you should use float or decimal as the conversion, but that is a secondary matter. If you have integers, convert with integer = int(number_string) If you don't

Re: String to Float, without introducing errors

2022-12-17 Thread Peter J. Holzer
On 2022-12-17 12:51:17 +0100, Paul St George wrote: > I have a large/long array of numbers in an external file. The numbers > look like this: > > -64550.727 > -64511.489 > -64393.637 [...] > > When I bring the numbers into my code, they are Strings. To use the > numbers in my code, I want to chan

Re: String to Float, without introducing errors

2022-12-17 Thread Alan Gauld
On 17/12/2022 11:51, Paul St George wrote: > I have a large/long array of numbers in an external file. The numbers look > like this: > > -64550.727 > -64511.489 > -64393.637 > -64196.763 > -63920.2 > When I bring the numbers into my code, they are Strings. To use the > numbers in my code, I wan

Re: String to Float, without introducing errors

2022-12-17 Thread Weatherby,Gerard
https://docs.python.org/3/library/decimal.html Get Outlook for iOS From: Python-list on behalf of Paul St George Sent: Saturday, December 17, 2022 6:51:17 AM To: python-list@python.org Subject: String to Float, without introducing errors

String to Float, without introducing errors

2022-12-17 Thread Paul St George
I have a large/long array of numbers in an external file. The numbers look like this: -64550.727 -64511.489 -64393.637 -64196.763 -63920.2 -63563.037 -63124.156 -62602.254 -61995.895 -61303.548 -60523.651 -59654.66 ... When I bring the numbers into my code, they are Strings. To use the numbers i