Hi Loïc,

I agree that we should not discuss about the theoretical aspects too much 
(while I disagree on your distinction, the API difference is just their 
mutability, so unless you refer to python intern algorithms for sort- 
/lookup- optimization (if so, excuse me) your distinction is just your 
personal taste)

The main point is the accidential assignment to list members / extension of 
the list in places where it's not obvious that the list of subject is part 
of the settings. Passing the whole settings object through functions makes 
no sense since you can always get it by importing, which minimizes the risk 
of accidently assigning to it.

Am Montag, 19. Januar 2015 18:53:26 UTC+1 schrieb Loïc Bistuer:
>
> 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 <kah...@cruise-systems.com 
> <javascript:>> 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-develop...@googlegroups.com <javascript:>. 
> > To post to this group, send email to django-d...@googlegroups.com 
> <javascript:>. 
> > 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/19ce444f-f676-460c-ba92-7033d4b6e25d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to