Hi Andreas,

As Florian pointed out, you can't mutate a tuple, but you can mutate the 
settings object, so using a tuple or a frozendict won't buy you much.

Regarding the theoretical perspective, tuples aren't meant to be immutable 
lists. Tuples are for heterogenous collections of fixed size (e.g. GPS 
coordinates); whereas lists are for homogenous collections of variable size, 
which suits perfectly our settings use-case. Of course Python being Python you 
can use them however you like but let's not talk about theory in that case.

Cheers

-- 
Loïc


> On Jan 20, 2015, at 00:15, Andreas Kahnert <kahn...@cruise-systems.com> wrote:
> 
> Well, yep. You can't prevent programmers to do stupid things in python. But 
> I'm kind of a theroretician and it hurts me if I see that exactly that what 
> it should not be is proposed as the standard. And for the dicts: In my 
> private code-base I use a frozendict c-package I wrote.
> 
> @Collin: The notation used within settings.py isn't that important. But I 
> think in the moment the framework constructs the settings object all 
> sequences (might be generators as well) should be turned into tuples.
> 
> For the trailing-comma-problem: I notate every (globally available) constant 
> sequence in the pattern:
> A = (
>     1,
>     2,
> )
> which is perfectly PEP-conformant and makes reodering elements manually also 
> more easy because you can cut'n'paste whole lines.
> 
> Am Montag, 19. Januar 2015 17:35:44 UTC+1 schrieb Florian Apolloner:
> On Monday, January 19, 2015 at 3:45:18 PM UTC+1, Andreas Kahnert wrote:
> I'm not talking about modifications inside the settings.py but in other 
> place. With lists, unexperienced devs might do things like: from django.conf 
> import settings; settings.TEMPLATE_DIRS[3] = '/my_tpls'; and expect to work 
> out good.
> 
> And with tuples they just do settings.TEMPLATE_DIRS = 
> list(settings.TEMPLATE_DIRS) followed by your example. What I am trying to 
> say is that a developer ignoring the docs will always run into issues, no 
> matter how hard we try to prevent it. 
> 
> This is realy just a question of logic: lists are mutable - settings are 
> immutable; see the conflict?
> 
> Well, what is your suggestion for the dictionaries in the settings then ;) In 
> the end it just doesn't matter if it's a list or a tuple -- you can "mutate" 
> it anyways. For the functionality of Django it makes no difference if you 
> altered the setting in place or just replace it -- stuff __will__ break. 
> 
> Cheers,
> Florian
> 
> -- 
> 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 django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> 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/07fd597a-01d2-4f6c-845b-5587a19b3263%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
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/5CF5D10A-9335-49A2-9CD4-7E0C7B81C8E6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to