[New-bugs-announce] [issue23506] Data Structure of Dict not changing its value as expected

Stan report at bugs.python.org
Tue Feb 24 05:51:45 CET 2015


New submission from Stan:

Expected the following code to change the value of the variable, it is not, comment are appreciated at this point.



GUMMIE_BEARS = ''

arr2 = { 'GUMMIE_BEARS' : GUMMIE_BEARS }

arr2['GUMMIE_BEARS'] = 'hello world'

print arr2['GUMMIE_BEARS']


print 'and this too' + GUMMIE_BEARS + '<---should be' # point #1


Expected output at point #1 should have 'hello world' contained within the string, it does not however.

# I note this description:
# Mutable variables – such as dictionaries and lists – are passed by reference, 
# and so if your function accepts mutable argument, it may modify the contents of that mutable variable 
# outside the scope of the function.

Thank You.

----------
messages: 236476
nosy: opensource3
priority: normal
severity: normal
status: open
title: Data Structure of Dict not changing its value as expected
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23506>
_______________________________________


More information about the New-bugs-announce mailing list