Code

Opened 6 years ago

Closed 6 years ago

#7020 closed (wontfix)

Convert read-only global lists to tuples

Reported by: Piotr Lewandowski <django@…> Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

According to DjangoSpecifications/Core/Threading - there are some global lists which rather should be converted to tuples:

As a matter of style, the read-only ones should really be tuples, not lists -- the 'say what you mean' idiom: if it shouldn't be modified, don't let it be by making it a tuple.


I've attached a patch that eliminates all read-only lists. Please notice that:

  • BLANK_CHOICE_DASH and BLANK_CHOICE_NONE are no longer single tuple wrapped in a list -- this change is slightly backwards-incompatible.
  • After commiting this patch DjangoSpecifications/Core/Threading (section Global lists) should be updated.

Attachments (1)

lists-to-tuples.diff (4.3 KB) - added by Piotr Lewandowski <django@…> 6 years ago.

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by Piotr Lewandowski <django@…>

comment:1 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

The wiki page you reference is in no way official Django policy or anything like that. It is written by one person to describe what they would like to see happen. Fortunately, the page does reference James Tabuer's blog post about homogeneous vs heterogeneous data structures, which, whilst I don't agree with it entirely, is quite a reasonable argument and a common data pattern in Python code.

Thus, this isn't worth changing. Python isn't C++. A lot of things are done by convention rather than enforced with a shotgun in the living room. This is one of those cases. Not harmful, not inhibitive to writing good code, not worth changing.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.