Yes, all those variables are pointing to the same object in memory (the 
list). If you just mutate the list, they're all still pointing to that same 
list. If you completely re-assign one of the variables to a different 
object, then that won't affect the other variables (which will still refer 
to the list). This might help: 
http://inst.eecs.berkeley.edu/~selfpace/cs9honline/Q2/mutation.html.

Anthony

On Wednesday, August 1, 2012 4:11:55 AM UTC-4, Annet wrote:
>
> In my application I build menus based on permissions. When a user logs in 
> I set all menus and dropdowns to []
>
>
> session.cmsadmin_menu=session.create_dropdown=session.retrieve_dropdown=...=[]
>
> Then based on queries I add items to the menus and dropdowns by iterating 
> through rows. What happens is, that when I add an item to 
> session.cmsadmin_menu it is also added to the other menus and dropdowns, so 
> basically all menu items are assigned to all menus and dropdowns because I 
> set them to [] in one statement.
>
> To solve this problem I had to set all the menus and dropdowns to [] in 
> separate statements:
>
> session.cmsadmin_menu=[]
> session.create_dropdown=[]
> session.retrieve_dropdown=[]
> ...=[]
>
> I wonder whether this is also true for variables stored in session and 
> variables in general, for I also have this in my code:
>
> session.userNodeID=session.userNodeName=session.userNodeMembership=[]
>
> these session variables get their value elsewhere in the code depending on 
> whether their values are present or not.
>
>
> Kind regards,
>
> Annet.
>

-- 



Reply via email to