On 12/17/2014 04:57 PM, Ryan Hiebert wrote: > >> On Dec 17, 2014, at 5:48 PM, Carl Meyer <[email protected]> wrote: >> >> On 12/17/2014 04:39 PM, Russell Keith-Magee wrote: >>> >>> I agree that lists are preferable to tuples. >>> >>> One option for handling existing projects might be to define our own >>> subclass of list that defines __add__, __iadd__, and __radd__ such that it >>> will accept a tuple, converting to a list, and raise a DeprecationWarning; >>> in a later version, we can replace that subclass with a simple list. We >>> wouldn't document this class, and it would only be used in >>> global_settings.py. This would cover the most common use case (adding >>> something to a default setting), and provide a migration path. Thoughts? >> >> FWIW, I think the subclass-of-list approach is neat enough, I'd be in >> favor of going ahead and doing this with that approach, if someone's >> motivated to write the patch. >> > What would __iadd__ do in this subclass? Would it behave like tuple and > create a new DjangoList, or would it behave like list and extend the > original list?
For maximum backwards-compatibility during the deprecation period, if it's called with a tuple, it should create and return a new tuple, I think. That way the deprecation warning only gets fired once for a particular setting, which is all that's needed, even if they go and add to the resulting value several more times. If it's called with a list, it should behave as a normal list does. And before you get too far, you may want to wait and see if any other core devs step in to tell me I'm crazy and there's no way we should have a deprecation path just to switch some settings from tuples to lists. (I'm only in favor of it myself because I think in practice the impact will be small.) Carl -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/54921BFD.9040809%40oddbird.net. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature
