Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Thomas Passin via Python-list
On 5/29/2024 10:59 AM, MRAB via Python-list wrote: On 2024-05-29 15:32, Thomas Passin via Python-list wrote: On 5/29/2024 8:55 AM, Kevin M. Wilson wrote: Please recall, I said the format for the email failed to retain the proper indents. I'll attach a picture of the code! Purpose; to uppercase

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Grant Edwards via Python-list
On 2024-05-29, Mats Wichmann via Python-list wrote: > On 5/29/24 08:02, Grant Edwards via Python-list wrote: >> On 2024-05-29, Chris Angelico via Python-list wrote: >> >>> print(f"if block {name[index]=} {index=}") >> >> Holy cow! How did I not know about the f-string {=} thing? > > It's more

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread MRAB via Python-list
On 2024-05-29 15:32, Thomas Passin via Python-list wrote: On 5/29/2024 8:55 AM, Kevin M. Wilson wrote: Please recall, I said the format for the email failed to retain the proper indents. I'll attach a picture of the code! Purpose; to uppercase every other letter in a string. Thanks all, KMW

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Barry Scott via Python-list
> On 29 May 2024, at 05:38, Kevin M. Wilson via Python-list > wrote: > > The format in this email is not of my making, should someone know, how to do > this so that it's a readable script do tell! > KMW Your mail program may have a plain-text mode to compose messages in try using that. B

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Thomas Passin via Python-list
On 5/29/2024 8:55 AM, Kevin M. Wilson wrote: Please recall, I said the format for the email failed to retain the proper indents. I'll attach a picture of the code! Purpose; to uppercase every other letter in a string. Thanks all, KMW Simpler is good, and readability is good. For a simple con

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Mats Wichmann via Python-list
On 5/29/24 08:02, Grant Edwards via Python-list wrote: On 2024-05-29, Chris Angelico via Python-list wrote: print(f"if block {name[index]=} {index=}") Holy cow! How did I not know about the f-string {=} thing? It's more recent than f-strings in general, so it's not that hard to miss. --

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Grant Edwards via Python-list
On 2024-05-29, Chris Angelico via Python-list wrote: > print(f"if block {name[index]=} {index=}") Holy cow! How did I not know about the f-string {=} thing? -- Grant -- https://mail.python.org/mailman/listinfo/python-list

Re: Formatted Output and Argument Parsing (was: Re: Flubbed it in the second interation through the string: range error... HOW?)

2024-05-29 Thread Chris Angelico via Python-list
On Wed, 29 May 2024 at 23:06, Dan Sommers via Python-list wrote: > (For the history-impaired, getopt existed long before Python and will > likely exist long after it, but getopt's "replacement" optparse lasted > only from 2003 until 2011.) Depends on your definition of "lasted". It's not getting

Formatted Output and Argument Parsing (was: Re: Flubbed it in the second interation through the string: range error... HOW?)

2024-05-29 Thread Dan Sommers via Python-list
On 2024-05-29 at 17:14:51 +1000, Chris Angelico via Python-list wrote: > I wouldn't replace str.format() everywhere, nor would I replace > percent encoding everywhere - but in this case, I think Thomas is > correct. Not because it's 2024 (f-strings were brought in back in > 2015, so they're hardl

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Thomas Passin via Python-list
On 5/29/2024 3:14 AM, Chris Angelico via Python-list wrote: On Wed, 29 May 2024 at 16:03, Cameron Simpson via Python-list wrote: By which Thomas means stuff like this: print(f'if block {name[index]} and index {index}') Notice the leading "f'". Personally I wouldn't even go that far, jus

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread MRAB via Python-list
x % 2 == 0): > 8 print('letter to upper = {}, index {}!'.format(name[index], index)) 9 name = name[index].upper() 10 print('if block {} and index {}'.format(name[index], index)) Index

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-29 Thread Chris Angelico via Python-list
On Wed, 29 May 2024 at 16:03, Cameron Simpson via Python-list wrote: > By which Thomas means stuff like this: > > print(f'if block {name[index]} and index {index}') > > Notice the leading "f'". Personally I wouldn't even go that far, just: > > print('if block', name[index], 'and index',

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Cameron Simpson via Python-list
On 29May2024 01:14, Thomas Passin wrote: Also, it's 2024 ... time to start using f-strings (because they are more readable than str.format()) By which Thomas means stuff like this: print(f'if block {name[index]} and index {index}') Notice the leading "f'". Personally I wouldn't even go t

Re: Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Thomas Passin via Python-list
name[index].upper() 10 print('if block {} and index {}'.format(name[index], index)) IndexError: string index out of range*** So, I'm doing something... Stupid!! *** "

Fw: Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Kevin M. Wilson via Python-list
ubbed it in the second interation through the string: range error... HOW? The following is my effort to understand how to process a string, letter, by letter: def myfunc(name):        index = 0    howmax = len(name)    # while (index <= howmax):    while (index < howmax):        if (index % 2 ==

Flubbed it in the second interation through the string: range error... HOW?

2024-05-28 Thread Kevin M. Wilson via Python-list
t('letter to upper = {}, index {}!'.format(name[index], index)) 9 name = name[index].upper() 10 print('if block {} and index {}'.format(name[index], index)) IndexError: string index out of range*** So, I&

Re: Python 2.7 range Function provokes a Memory Error

2023-03-06 Thread Chris Angelico
at's because Py2 has two different integer types, int and long. > I am raising this because, > > (a) IF xrange in Py3 is a simple "port" from Py2, then it won't handle > Python integers either. > > AND > > (b) IF xrange in Py3 is intended to be equivalent t

Re: Python 2.7 range Function provokes a Memory Error

2023-03-06 Thread Stephen Tucker
n it won't handle Python integers either. AND (b) IF xrange in Py3 is intended to be equivalent to range (which, even in Py2, does handle Python integers) THEN It could be argued that xrange in Py3 needs some attention from the developer(s). Stephen Tucker. On Thu, Mar 2, 2023 at 6:24 PM

Re: Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread Jon Ribbens via Python-list
On 2023-03-02, Stephen Tucker wrote: > The range function in Python 2.7 (and yes, I know that it is now > superseded), provokes a Memory Error when asked to deiliver a very long > list of values. > > I assume that this is because the function produces a list which it then >

Re: Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread Chris Angelico
On Thu, 2 Mar 2023 at 22:27, Stephen Tucker wrote: > > Hi, > > The range function in Python 2.7 (and yes, I know that it is now > superseded), provokes a Memory Error when asked to deiliver a very long > list of values. > > I assume that this is because the function produ

Re: Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread 2QdxY4RzWzUUiLuE
On 2023-03-02 at 11:25:49 +, Stephen Tucker wrote: > The range function in Python 2.7 (and yes, I know that it is now > superseded), provokes a Memory Error when asked to deiliver a very long > list of values. > > I assume that this is because the function produces a lis

Python 2.7 range Function provokes a Memory Error

2023-03-02 Thread Stephen Tucker
Hi, The range function in Python 2.7 (and yes, I know that it is now superseded), provokes a Memory Error when asked to deiliver a very long list of values. I assume that this is because the function produces a list which it then iterates through. 1. Does the range function in Python 3.x

Re: Comparing sequences with range objects

2022-04-11 Thread Antoon Pardon
Op 11/04/2022 om 02:31 schreef Dan Stromberg: It sounds a little like you're looking for interval arithmetic. Maybe https://pypi.org/project/python-intervals/1.5.3/ ? Not completely but it suggested an idea to explore. -- Antoon. -- https://mail.python.org/mailman/listinfo/python-list

Re: Comparing sequences with range objects

2022-04-11 Thread Antoon Pardon
Op 11/04/2022 om 02:01 schreef duncan smith: On 10/04/2022 21:20, Antoon Pardon wrote: Op 9/04/2022 om 02:01 schreef duncan smith: On 08/04/2022 22:08, Antoon Pardon wrote: Well my first thought is that a bitset makes it less obvious to calulate the size of the set or to iterate over it

Re: Comparing sequences with range objects

2022-04-10 Thread Dan Stromberg
4:19 AM Antoon Pardon wrote: > >> I am working with a list of data from which I have to weed out duplicates. >> At the moment I keep for each entry a container with the other entries >> that are still possible duplicates. >> >> The problem is sometimes that is all

Re: Comparing sequences with range objects

2022-04-10 Thread 2QdxY4RzWzUUiLuE
On 2022-04-10 at 22:20:33 +0200, Antoon Pardon wrote: > > > Op 9/04/2022 om 02:01 schreef duncan smith: > > On 08/04/2022 22:08, Antoon Pardon wrote: > > > > > > Well my first thought is that a bitset makes it less obvious to calulate > > > the size of the set or to iterate over its elements.

Re: Comparing sequences with range objects

2022-04-10 Thread Dan Stromberg
ach entry a container with the other entries > that are still possible duplicates. > > The problem is sometimes that is all the rest. I thought to use a range > object for these cases. Unfortunatly I sometimes want to sort things > and a range object is not comparable with a list or a tupl

Re: Comparing sequences with range objects

2022-04-10 Thread duncan smith
On 10/04/2022 21:20, Antoon Pardon wrote: Op 9/04/2022 om 02:01 schreef duncan smith: On 08/04/2022 22:08, Antoon Pardon wrote: Well my first thought is that a bitset makes it less obvious to calulate the size of the set or to iterate over its elements. But it is an idea worth exploring.

Re: Comparing sequences with range objects

2022-04-10 Thread Antoon Pardon
Op 9/04/2022 om 02:01 schreef duncan smith: On 08/04/2022 22:08, Antoon Pardon wrote: Well my first thought is that a bitset makes it less obvious to calulate the size of the set or to iterate over its elements. But it is an idea worth exploring. def popcount(n):     """     Returns the

Re: Comparing sequences with range objects

2022-04-09 Thread Ian Hobson
ally contain all other records (which in this case are the indexes into the population list). But that will eat a lot of memory. So I want some object that behaves as if it is a (immutable) list of all these indexes without actually containing them. A range object almost works, with the only probl

Re: Comparing sequences with range objects

2022-04-09 Thread Christian Gollwitzer
re the indexes into the population list). But that will eat a lot of memory. So I want some object that behaves as if it is a (immutable) list of all these indexes without actually containing them. A range object almost works, with the only problem it is not comparable with a list. Then writ

Re: Comparing sequences with range objects

2022-04-09 Thread duncan smith
population list). But that will eat a lot of memory. So I want some object that behaves as if it is a (immutable) list of all these indexes without actually containing them. A range object almost works, with the only problem it is not comparable with a list. Is there any reason why you can't

Re: Comparing sequences with range objects

2022-04-08 Thread Antoon Pardon
of memory. So I want some object that behaves as if it is a (immutable) list of all these indexes without actually containing them. A range object almost works, with the only problem it is not comparable with a list. Is there any reason why you can't use ints? Just set the relevant bits.

Re: Comparing sequences with range objects

2022-04-08 Thread duncan smith
d to be unusable, the bucket to be associated with it should conceptually contain all other records (which in this case are the indexes into the population list). But that will eat a lot of memory. So I want some object that behaves as if it is a (immutable) list of all these indexes without actually containi

Re: Comparing sequences with range objects

2022-04-08 Thread Antoon Pardon
should conceptually contain all other records (which in this case are the indexes into the population list). But that will eat a lot of memory. So I want some object that behaves as if it is a (immutable) list of all these indexes without actually containing them. A range object almost works, with t

Re: Comparing sequences with range objects

2022-04-07 Thread Chris Angelico
On Fri, 8 Apr 2022 at 16:26, Peter J. Holzer wrote: > Unless you have a unique immutable identifier that's enforced by > some authority (like a social security number[1]), I don't think there > is a chance to do that reliably in a program (although with enough data, > a heuristic may be good enoug

Re: Comparing sequences with range objects

2022-04-07 Thread Peter J. Holzer
On 2022-04-07 17:16:41 +0200, Antoon Pardon wrote: > Op 7/04/2022 om 16:08 schreef Joel Goldstick: > > On Thu, Apr 7, 2022 at 7:19 AM Antoon Pardon wrote: > > > I am working with a list of data from which I have to weed out duplicates. > > > At the moment I keep for each entry a container with the

Re: Comparing sequences with range objects

2022-04-07 Thread MRAB
are still possible duplicates. The problem is sometimes that is all the rest. I thought to use a range object for these cases. Unfortunatly I sometimes want to sort things and a range object is not comparable with a list or a tuple. So I have a list of items where each item is itself a list or range

Re: Comparing sequences with range objects

2022-04-07 Thread Dieter Maurer
ifferent bits. > >So all records with the same firstname can be duplicates. But if I have >a record in which the firstname is missing, it can at that point be >a duplicate of all other records. The description is still not clear enough. Especially, it does not show where `range` objects

Re: Comparing sequences with range objects

2022-04-07 Thread Antoon Pardon
is sometimes that is all the rest. I thought to use a range object for these cases. Unfortunatly I sometimes want to sort things and a range object is not comparable with a list or a tuple. So I have a list of items where each item is itself a list or range object. I of course could sort this by

Re: Comparing sequences with range objects

2022-04-07 Thread Joel Goldstick
is all the rest. I thought to use a range > object for these cases. Unfortunatly I sometimes want to sort things > and a range object is not comparable with a list or a tuple. > > So I have a list of items where each item is itself a list or range object. > I of course could sort this by

Comparing sequences with range objects

2022-04-07 Thread Antoon Pardon
I am working with a list of data from which I have to weed out duplicates. At the moment I keep for each entry a container with the other entries that are still possible duplicates. The problem is sometimes that is all the rest. I thought to use a range object for these cases. Unfortunatly I

Re: To check if number is in range(x,y)

2020-12-14 Thread Tim Chase
On 2020-12-14 21:21, Schachner, Joseph wrote: > >>> r = range(10) > So r is a list containing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 In Python 3.x, r is *not* a list. It is a custom object/class. > >>> 2 in r > True > As expected. I'm not sure wha

Re: To check if number is in range(x,y)

2020-12-14 Thread Dan Stromberg
On Mon, Dec 14, 2020 at 3:07 PM Dan Stromberg wrote: > > On Mon, Dec 14, 2020 at 1:23 PM Schachner, Joseph < > joseph.schach...@teledyne.com> wrote: > >> >>> r = range(10) >> So r is a list containing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 >> > To get a lis

Re: To check if number is in range(x,y)

2020-12-14 Thread Dan Stromberg
On Mon, Dec 14, 2020 at 1:23 PM Schachner, Joseph < joseph.schach...@teledyne.com> wrote: > >>> r = range(10) > So r is a list containing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 > To get a list of consecutive int's, you can use, for EG: r = list(range(10)) -- https://mail.pytho

Re: To check if number is in range(x,y)

2020-12-14 Thread 2QdxY4RzWzUUiLuE
On 2020-12-14 at 21:21:43 +, "Schachner, Joseph" wrote: > >>> r = range(10) > So r is a list containing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 In a number of ways, r behaves as if it were that list, but r is definitely not that list: >>> r = range(10) >&g

RE: To check if number is in range(x,y)

2020-12-14 Thread Schachner, Joseph
>>> r = range(10) So r is a list containing 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 >>> 2 in r True As expected. >>> 2.5 in r False Also as expected. If you did int(floor(2.5)) in 5 that would be true. >>> r = range(1, 10, 2) >>> 2 in r Fa

Re: To check if number is in range(x,y)

2020-12-12 Thread Bischoop
On 2020-12-12, Tim Chase wrote: > > Hopefully this gives you the hints that you need to troubleshoot. > > -tkc > > > > Yes it explains a lot. Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: To check if number is in range(x,y)

2020-12-12 Thread 2QdxY4RzWzUUiLuE
On 2020-12-12 at 10:51:00 -0600, Tim Chase wrote: > If you want numeric-range checks, Python provides the lovely > double-comparison syntax: > > >>> x = 5 > >>> 2 < x < 10 > True Not just numbers: >>> 'm' < 'n

Re: To check if number is in range(x,y)

2020-12-12 Thread Tim Chase
On 2020-12-12 15:12, Bischoop wrote: > I need to check if input number is 1-5. Whatever I try it's not > working. Here are my aproaches to the problem: https://bpa.st/H62A > > What I'm doing wrong and how I should do it? A range is similar to a list in that it contains j

Re: To check if number is in range(x,y)

2020-12-12 Thread Bischoop
Got it solved here: https://bpa.st/BFJA -- https://mail.python.org/mailman/listinfo/python-list

Re: To check if number is in range(x,y)

2020-12-12 Thread Oscar
ng. That string is not in the range you compare it to. You need to convert it to an int: choice = int(input.. ) This is assuming you want a whole number. You compare it against the list of numbers [1, 2, 3, 4, 5]. If 2.4 is also a valid number, you need a different comparison. 2.4 is not in this li

To check if number is in range(x,y)

2020-12-12 Thread Bischoop
I need to check if input number is 1-5. Whatever I try it's not working. Here are my aproaches to the problem: https://bpa.st/H62A What I'm doing wrong and how I should do it? -- Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: To check if number is in range(x,y)

2020-12-12 Thread Bischoop
I've also convert the choice to int() but doesn't help. -- https://mail.python.org/mailman/listinfo/python-list

Re: To check if number is in range(x,y)

2020-12-12 Thread Bischoop
On 2020-12-12, Oscar wrote: > In article , > Bischoop wrote: >>I've also convert the choice to int() but doesn't help. > > Oh.. did not read this yet. How did you do this? In both places after > the input or during the comparison? If so, in which version? Only the > first version would work. The

Re: To check if number is in range(x,y)

2020-12-12 Thread Oscar
In article , Bischoop wrote: >I've also convert the choice to int() but doesn't help. Oh.. did not read this yet. How did you do this? In both places after the input or during the comparison? If so, in which version? Only the first version would work. The other two are just plain wrong. -- [J|O

Re: About float/double type number in range.

2020-08-26 Thread Rob Cliffe via Python-list
On 26/08/2020 12:02, Peter J. Holzer wrote: On 2020-08-26 22:40:36 +1200, dn via Python-list wrote: On 26/08/2020 19:58, Joel Goldstick wrote: [...] <<< Code NB Python v3.8 >>> def fp_range( start:float, stop:float, step:float=1.0 )->float: ""&quo

Re: About float/double type number in range.

2020-08-26 Thread Terry Reedy
On 8/26/2020 6:40 AM, dn via Python-list wrote: def fp_range( start:float, stop:float, step:float=1.0 )->float:     """Generate a range of floating-point numbers."""     if stop <= start:     raise OverflowError( "RangeError: start must be less

Re: About float/double type number in range.

2020-08-26 Thread Richard Damon
On 8/25/20 10:39 PM, ADITYA wrote: >Dear Sir/Ma’am > >I am requesting you to satisfy me about float number in Range function, >because in the argument of range we can take integer but not double or >float whenever double as well as float are integer in nature but w

Re: About float/double type number in range.

2020-08-26 Thread Peter J. Holzer
On 2020-08-26 22:40:36 +1200, dn via Python-list wrote: > On 26/08/2020 19:58, Joel Goldstick wrote: > > On Wed, Aug 26, 2020 at 3:43 AM ADITYA wrote: > > > Dear Sir/Ma’am > > > > > > I am requesting you to satisfy me about float number in Rang

Re: About float/double type number in range.

2020-08-26 Thread dn via Python-list
On 26/08/2020 19:58, Joel Goldstick wrote: On Wed, Aug 26, 2020 at 3:43 AM ADITYA wrote: Dear Sir/Ma’am I am requesting you to satisfy me about float number in Range function, because in the argument of range we can take integer but not double or float whenever double as well

Re: About float/double type number in range.

2020-08-26 Thread Joel Goldstick
On Wed, Aug 26, 2020 at 3:43 AM ADITYA wrote: > >Dear Sir/Ma’am > >I am requesting you to satisfy me about float number in Range function, >because in the argument of range we can take integer but not double or >float whenever double as well as float are integer

About float/double type number in range.

2020-08-26 Thread ADITYA
Dear Sir/Ma’am I am requesting you to satisfy me about float number in Range function, because in the argument of range we can take integer but not double or float whenever double as well as float are integer in nature but when we use double/float in, it gives error that- “'

Re: Button press event - event handling and picking: IndexError: list index out of range

2020-06-09 Thread Cousin Stanley
Caledonian26 wrote: > However, I keep getting the error: > > IndexError: list index out of range. > > Could anyone give me a helping hand > as to where I am going wrong? > I appended a single arbitrary value for limits since the limits list ha

Re: Button press event - event handling and picking: IndexError: list index out of range

2020-06-07 Thread DL Neil via Python-list
On 8/06/20 10:38 AM, MRAB wrote: On 2020-06-07 23:24, DL Neil via Python-list wrote: On 8/06/20 7:06 AM, Caledonian26 wrote: ... However, I keep getting the error: IndexError: list index out of range. Could anyone give me a helping hand as to where I am going wrong? When things go wrong

Re: Button press event - event handling and picking: IndexError: list index out of range

2020-06-07 Thread MRAB
On 2020-06-07 23:24, DL Neil via Python-list wrote: On 8/06/20 7:06 AM, Caledonian26 wrote: ... However, I keep getting the error: IndexError: list index out of range. Could anyone give me a helping hand as to where I am going wrong? When things go wrong, Python tries to be helpful by

Re: Button press event - event handling and picking: IndexError: list index out of range

2020-06-07 Thread DL Neil via Python-list
On 8/06/20 7:06 AM, Caledonian26 wrote: ... However, I keep getting the error: IndexError: list index out of range. Could anyone give me a helping hand as to where I am going wrong? When things go wrong, Python tries to be helpful by providing a "traceback". Please copy-paste

Button press event - event handling and picking: IndexError: list index out of range

2020-06-07 Thread Caledonian26
larMappable(cmap=cmap, norm=norm) plt.gcf().colorbar(sm) plt.show() 4. Here, a different colour is assigned to each bar in the bar chart depending on the values in the column 'colourofbars'. I then try to plot a legend showing this colour gradient scale. However, I keep getting the error: IndexError: list index out of range. Could anyone give me a helping hand as to where I am going wrong? -- https://mail.python.org/mailman/listinfo/python-list

Re: Determining index of range of values in a matrix

2020-05-19 Thread DL Neil via Python-list
On 19/05/20 6:40 AM, swaroop.sahoo...@gmail.com wrote: Hi All, I am using python for doing the following: I have a matrix which has dimension of 174*993. Each row of the matrix has some numbers in the range of 30-30.5. I would like to determine the index of the numbers in the range of 30-30.5 in

Determining index of range of values in a matrix

2020-05-18 Thread swaroop . sahoo769
Hi All, I am using python for doing the following: I have a matrix which has dimension of 174*993. Each row of the matrix has some numbers in the range of 30-30.5. I would like to determine the index of the numbers in the range of 30-30.5 in each row. I can determine the index of the numbers in

Re: Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
oh not a real bug, i thought the effect had to do with generator working rather a simple times 0 Abdur-Rahmaan Janhangeer Mauritius On Sat, 13 Jul 2019, 16:24 Chris Angelico, wrote: > On Sat, Jul 13, 2019 at 10:02 PM Abdur-Rahmaan Janhangeer > wrote: > > > > @Thomas thought was a generator bug

Re: Accumulate , Range and Zeros

2019-07-13 Thread Chris Angelico
On Sat, Jul 13, 2019 at 10:02 PM Abdur-Rahmaan Janhangeer wrote: > > @Thomas thought was a generator bug since instead of returning the usual > nums it was returning 0 0 0 ... When you find a bug or strange bit of behaviour, first make sure you can reproduce it. Then create a small, self-containe

Re: Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
@Thomas thought was a generator bug since instead of returning the usual nums it was returning 0 0 0 ... -- https://mail.python.org/mailman/listinfo/python-list

Re: Accumulate , Range and Zeros

2019-07-13 Thread Thomas Jollans
On 13/07/2019 11:54, Abdur-Rahmaan Janhangeer wrote: > Greetings, > > Given this snippet > > from itertools import * > import operator > > > x = [1, 2, 3] # [0, 1, 2, 3, ..., 10] > > y = accumulate(x, operator.mul) > > print(list(y)) > > wh

Re: Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
@Frank So simple. Thanks! Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: Accumulate , Range and Zeros

2019-07-13 Thread Dan Sommers
On 7/13/19 5:54 AM, Abdur-Rahmaan Janhangeer wrote: > > Greetings, > > > > Given this snippet > > > > from itertools import * > > import operator > > > > > > x = [1, 2, 3] # [0, 1, 2, 3, ..., 10] > > > > y = accumulate(x, oper

Re: Accumulate , Range and Zeros

2019-07-13 Thread Frank Millman
On 2019-07-13 11:54 AM, Abdur-Rahmaan Janhangeer wrote: Greetings, Given this snippet from itertools import * import operator x = [1, 2, 3] # [0, 1, 2, 3, ..., 10] y = accumulate(x, operator.mul) print(list(y)) why does x = list(range(5)) produces only zeros? That is an easy one. By

Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
Greetings, Given this snippet from itertools import * import operator x = [1, 2, 3] # [0, 1, 2, 3, ..., 10] y = accumulate(x, operator.mul) print(list(y)) why does x = list(range(5)) produces only zeros? -- Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur

Re: Copying a row from a range of Excel files to another

2019-06-28 Thread Cecil Westerhof
MRAB writes: > On 2019-06-26 22:14, Cecil Westerhof wrote: >> MRAB writes: >> >>> Does Workbook support the 'with' statement? >>> >>> If it does, then that's the best way of doing it. >>> >>> (Untested) >>> >>> with Workbook() as wb_out: >>> for filepath in filepathArr: >>>

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Sayth Renshaw
Cecil Westerhof wrote: > I was asked to copy a certain line from about 300 Excel lines to a new > Excel file. That is not something I would like to do by hand and I > immediately thought: that should be possible with Python. > > And it is. I was surprised how fast I could write that with openpyx

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread MRAB
On 2019-06-26 22:14, Cecil Westerhof wrote: MRAB writes: Does Workbook support the 'with' statement? If it does, then that's the best way of doing it. (Untested) with Workbook() as wb_out: for filepath in filepathArr: current_row = [] with load_workbook(

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
MRAB writes: > Does Workbook support the 'with' statement? > > If it does, then that's the best way of doing it. > > (Untested) > > with Workbook() as wb_out: > for filepath in filepathArr: > current_row = [] > > with load_workbook(filepath) as wb_in: >

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread MRAB
On 2019-06-26 13:15, Cecil Westerhof wrote: Cecil Westerhof writes: I was asked to copy a certain line from about 300 Excel lines to a new Excel file. That is not something I would like to do by hand and I immediately thought: that should be possible with Python. And it is. I was surprised ho

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
Cecil Westerhof writes: > Is it necessary to close the workbooks to circumvent a resource > leak? Still like to know. When not necessary it is better not to cloes them I think. > Is it a problem when a workbook is closed two times? If so I need to > make sure that this is not possible. That i

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
Cecil Westerhof writes: > I was asked to copy a certain line from about 300 Excel lines to a new > Excel file. That is not something I would like to do by hand and I > immediately thought: that should be possible with Python. > > And it is. I was surprised how fast I could write that with openpyx

Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
I was asked to copy a certain line from about 300 Excel lines to a new Excel file. That is not something I would like to do by hand and I immediately thought: that should be possible with Python. And it is. I was surprised how fast I could write that with openpyxl. My first try was not very neat,

Re: Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread Terry Reedy
)  # 0.5414720812182742 print(xsd) # 0.15748041033663002 print(str("{6.5f}".format(xm))) I get the following error: IndexError: tuple index out of range Can someone suggest me why I am getting this error and how to overcome this? Show us the full traceback after expanding and reducing t

Re: Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread Rob Gaddi
) # 0.15748041033663002 print(str("{6.5f}".format(xm))) I get the following error: IndexError: tuple index out of range Can someone suggest me why I am getting this error and how to overcome this? Thanks in advance print(str("{:6.5f}".format(xm))) You want to apply the format 6.5

Why I am getting IndexError: tuple index out of range when converting a float value to a string?

2019-06-11 Thread madhavanbomidi
.format(xm))) I get the following error: IndexError: tuple index out of range Can someone suggest me why I am getting this error and how to overcome this? Thanks in advance -- https://mail.python.org/mailman/listinfo/python-list

Re: Sum of few numbers by using for and range

2019-02-17 Thread DL Neil
On 18/02/19 8:32 AM, Chris Angelico wrote: On Mon, Feb 18, 2019 at 6:12 AM DL Neil wrote: The reason this course caught my attention (and which is relevant to you, per Chris' and Dennis' recent advice) is that the course revolves around an 'active textbook'. This intersperses learning material

Re: Sum of few numbers by using for and range

2019-02-17 Thread Chris Angelico
On Mon, Feb 18, 2019 at 6:12 AM DL Neil wrote: > > sure you truly understand what is going on. Try to piece together what > > a section of code is doing, step by step. Write down on a piece of > > paper what the variables are at each point in the program. Then, AFTER > > doing the work manually, r

Re: Sum of few numbers by using for and range

2019-02-17 Thread DL Neil
^Bart, Which course are you attempting? What are you using as learning material? (it seems ineffectual) - further comments interspersed, below:- On 18/02/19 5:30 AM, Chris Angelico wrote: On Mon, Feb 18, 2019 at 3:26 AM ^Bart wrote: I need to do what I wrote in the subject but... I don't u

Re: Sum of few numbers by using for and range

2019-02-17 Thread Chris Angelico
nd number:")) > number3 = int( input("Insert the third number:")) > > print("Total amount is:") > > for x in range(number1,number3): > y = x+x > print(y) > When you want homework help, it is extremely useful to post the entire challenge yo

Sum of few numbers by using for and range

2019-02-17 Thread ^Bart
print("Total amount is:") for x in range(number1,number3): y = x+x print(y) Regards. ^Bart -- https://mail.python.org/mailman/listinfo/python-list

Re: range

2018-06-25 Thread Schachner, Joseph
ote, today: for i in range(1): pass # 100 million on Python 2, it used up 1.8GB, up to the limit of my RAM, and it took several minutes to regain control of my machine (and it never did finish). You don't expect that in 2018 when executing a simple empty loop. On Py 2

Re: curious asymmetry in range limiting

2018-03-20 Thread Wolfgang Maier
On 03/20/2018 03:21 PM, Robin Becker wrote: I don't know how I never came across this before, but there's a curious asymmetry in the way ranges are limited Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "lic

Re: curious asymmetry in range limiting

2018-03-20 Thread Robin Becker
So eventually I tried this C:\code\hg-repos\reportlab>\python36\python -c"s='0123456789';print(repr(s[-5:15]))" '56789' C:\code\hg-repos\reportlab>\python36\python -c"s='0123456789';print(repr(s[-6:15]))" '456789' and the light dawned :) seems the negative indexes rules apply to both On

curious asymmetry in range limiting

2018-03-20 Thread Robin Becker
I don't know how I never came across this before, but there's a curious asymmetry in the way ranges are limited Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> s = '01234567

Re: Teaching the "range" function in Python 3

2017-07-02 Thread Rick Johnson
On Saturday, July 1, 2017 at 12:48:39 AM UTC-5, Christian Gollwitzer wrote: > Am 30.06.17 um 04:33 schrieb Rick Johnson: > > And to further drive home the point, you can manually > > insert a list literal to prove this: > > > > >>> range(10) &g

Re: Teaching the "range" function in Python 3

2017-07-02 Thread Rick Johnson
On Thursday, June 29, 2017 at 9:58:23 PM UTC-5, Chris Angelico wrote: > On Fri, Jun 30, 2017 at 12:33 PM, Rick Johnson > > A better *FIRST* example would be something like this: > > > > def add(x, y): > > return x + y > > > > When teaching a student about functions, the first step is >

  1   2   3   4   5   6   7   8   9   10   >