Hello,
On Tue, 24 Nov 2020 19:36:03 +
"Mathew M. Noel via Python-ideas" wrote:
> Python uses an index of -1 to index the last element in a list. Since
> -1 occurs before 0 we might think of the elements of the linear list
> are being bent into a circle making the last element occur before th
Hi Mathew, welcome!
My responses interleaved with your comments.
On Wed, Nov 25, 2020 at 04:29:17AM +, Mathew M. Noel via Python-ideas wrote:
> As discussed earlier on the post on 'Circular Indexing', considering
> interpreting indices that lie outside the range 0 to n-1 modulo n for
> li
Hi all, this is a general feeler for if this idea has any traction:
All too often I see the following pattern in asyncio 3rd-party libs, either
in their own source code or in the inusage:
```
inst = SomeClass()
await inst.initialize()
```
What happens here is that, since coroutines cannot be used
25.11.20 06:29, Mathew M. Noel via Python-ideas пише:
> 2.) If circular indexing is used then instead of using a double FOR loop
> to go through a loop twice we can iterate from 0 to 2n !
If you just need to iterate list indices twice, iterate range(-n, n)
instead of range(n).
The power in programming is the simplicity in keyword and instruction function, I do believe. As much as I love the concept, I feel the use of a data structure to handle such cases circular indexing is needed is more appropriate than changing loop statement behavior.At times I heavily rely on index
If circular indexing is used then instead of using a double FOR loop to go
through a list M times we can iterate from 0 to M*N (where N is the length of
the list) !!!
Almost all Machine Learning (ML) algorithms iterate for some predefined epochs
over a large data-set. So a double FOR loop is e
A while back I could make a proof of concept of this with current Python,
no modifications needed.
The text is in portuguese -by I believe automatic translation should be
enough for the non-code
parts.
https://pt.stackoverflow.com/questions/390755/%c3%89-poss%c3%advel-definir-como-async-o-m%c3%a9
So why don't you implement your own type/wrapper with the semantics you need?
Le mer. 25 nov. 2020 à 18:49, Mathew M. Noel via Python-ideas
a écrit :
>
> If circular indexing is used then instead of using a double FOR loop to go
> through a list M times we can iterate from 0 to M*N (where N is t
days_of_the_week[14 % 7]
There ya go!
On Wed, Nov 25, 2020 at 12:51 PM Mathew M. Noel via Python-ideas <
python-ideas@python.org> wrote:
> If circular indexing is used then instead of using a double FOR loop to
> go through a list M times we can iterate from 0 to M*N (where N is the
> length of
You've started three separate threads to propose something that has exactly
zero chance of happening, and would be of limited use in uncommon cases.
And that would break literally billions of lines of working code.
If you want the modulo operator, you are more than welcome to use it. If
you want t
On 26/11/20 2:30 am, nathan.w.edwa...@outlook.com wrote:
At times I heavily rely on index out of bound exceptions to reduce the
number of lines necessary for error checking.
This is a downside to the negative indexing scheme -- you
can't tell the difference between a backwards index and an
erro
On Thu, Nov 26, 2020 at 12:07:56PM +1300, Greg Ewing wrote:
> On 26/11/20 2:30 am, nathan.w.edwa...@outlook.com wrote:
> >At times I heavily rely on index out of bound exceptions to reduce the
> >number of lines necessary for error checking.
>
> This is a downside to the negative indexing scheme
On Wed, Nov 25, 2020 at 3:44 PM Steven D'Aprano wrote:
> Obviously you can tell the two apart, so I'm confused by your comment.
>
What I imagined while reading Greg's comment was trying to explain to a
student why this didn't work the way they expected. "Ok, so in the first
case I'm *not* start
On 11/25/2020 6:41 PM, Steven D'Aprano wrote:
On Thu, Nov 26, 2020 at 12:07:56PM +1300, Greg Ewing wrote:
On 26/11/20 2:30 am, nathan.w.edwa...@outlook.com wrote:
At times I heavily rely on index out of bound exceptions to reduce the
number of lines necessary for error checking.
This is a do
On 26/11/20 12:41 pm, Steven D'Aprano wrote:
a = "abcdef"
a[-2] # returns a result
Yes, but did you *intend* that result, or did the -2
result from a calculation that should have returned a
positive index but went wrong? Python has no way to
tell.
--
Greg
___
Why not use list_name[-n%N] whenever you need to use negative indices and raise
an index out of bounds exception with negative indices like other programming
languages?
From: Calvin Spealman
Sent: Thursday, November 26, 2020 1:00 AM
To: Mathew M. Noel
Cc: pyt
Hmm... In the end I think the language design issue is with functions (and
how they capture variable references rather than values), and fixing it by
changing the for-loop is still just a band-aid, with other problems and
inconsistencies. Agreed that the fix 'x=x' essentially always works, and
that
Because it's not backward-incompatible with the behaviour of positive
indices.
Le jeu. 26 nov. 2020 à 05:56, Mathew M. Noel via Python-ideas <
python-ideas@python.org> a écrit :
>
> Why not use list_name[-n%N] whenever you need to use negative indices and
> raise an index out of bounds exception
Hello,
On Thu, 26 Nov 2020 13:27:46 +1300
Greg Ewing wrote:
> On 26/11/20 12:41 pm, Steven D'Aprano wrote:
> > a = "abcdef"
> > a[-2] # returns a result
>
> Yes, but did you *intend* that result, or did the -2
> result from a calculation that should have returned a
> positive index
19 matches
Mail list logo