Opened 3 years ago

Closed 3 years ago

#20466 closed Cleanup/optimization (wontfix)

Idiomatic Python: use lists instead of tuples where appropriate

Reported by: Patryk Zawadzki Owned by: Patryk Zawadzki
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently most of the documented lists are actually tuples. This is uncalled for and not really pythonic.

Python authors have already stated that tuple was not a frozen list. Let's stick to using tuples where tuples fit, eg. where a namedtuple could be used instead but would be an overkill.

Change History (7)

comment:1 Changed 3 years ago by Patryk Zawadzki

Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to Patryk Zawadzki
Patch needs improvement: unset
Status: newassigned

comment:2 Changed 3 years ago by Anssi Kääriäinen

Triage Stage: UnreviewedAccepted

comment:3 Changed 3 years ago by Marc Tamlyn

I'm concerned about the backwards compatibility of this patch - I know in a number of my projects I import the default value from global settings and combine it with another list/tuple of my own appropriately. It's a minor issue, but I'm not sure it's worth breaking things for the sake of a little properness. Nothing is broken at the moment.

comment:4 Changed 3 years ago by Patryk Zawadzki

@mjtamlyn, can you provide a case that no longer works?

comment:5 Changed 3 years ago by Tim Graham

I had similar concerns. For example:

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS + ('myapp.myprocessor',)

After this change, the above code would throw an error: TypeError: can only concatenate list (not "tuple") to list.

comment:6 Changed 3 years ago by Aymeric Augustin

Like Marc and Tim, I don't think the disruption caused by this change is really worth it.

comment:7 Changed 3 years ago by Tim Graham

Resolution: wontfix
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top