Opened 2 years ago

Closed 2 years ago

#20466 closed Cleanup/optimization (wontfix)

Idiomatic Python: use lists instead of tuples where appropriate

Reported by: patrys Owned by: patrys
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 2 years ago by patrys

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to patrys
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 2 years ago by akaariai

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by mjtamlyn

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 2 years ago by patrys

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

comment:5 Changed 2 years ago by timo

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 2 years ago by aaugustin

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

comment:7 Changed 2 years ago by timo

  • Resolution set to wontfix
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.
Back to Top