[Tutor] Clarification on .format() Method and Negative Indices in Python

Mats Wichmann mats at wichmann.us
Wed Sep 25 12:28:43 EDT 2024


On 9/25/24 09:03, Alan Gauld via Tutor wrote:
> On 25/09/2024 03:23, Xingyuan Shi via Tutor wrote:
> 
>> was curious as to why negative indices like {-1} are not supported in this
>> method, while negative indexing works perfectly with lists and other
>> sequences in Python.
> 
> Yes, it is odd. I can see why it might be useful too.
> OTOH its not something I've ever looked for so maybe whoever
> designed it just didn't think it necessary.
> 
> However, when it comes to design decisions you are probably
> better asking on the main python mailing list as more of
> the core team hang out there.
> 
> You could also try the Python dev mailing list and look for
> the PEP that covers string formatting(3101). You might find
> a discussion there.

the Python dev list is dead - there was (grudging) agreement to move all 
that to discuss.python.org, and that's probably the best place to ask 
the question, as things are fairly well categorized and thus tend to 
reach the right people (python-dev was kind of like a firehose for  some 
of the developers who didn't have much time, part of the reason for its 
demise).

If you find anything useful it might be fun to post it here, too!

> 
> Here is the original PEP:
> 
> https://peps.python.org/pep-3101/


More information about the Tutor mailing list