Python Warts

misfeatures and other problems
PERL| PHP| PYTHON| RUBY
Answers: (all questions)
(question)
Question:
#!/usr/bin/python

a = ([1,2,3], [7,8,9])

try:
	a[0] += [4,5,6]
except Exception, e:
	print "Error: %s" % e

print "a=%s" % str(a)
Answer:
Output:
Error: object doesn't support item assignment
a=([1, 2, 3, 4, 5, 6], [7, 8, 9])
Python manages to modify the [1,2,3] list in-place, but then it fails after making the changes, because tuples are not mutable.
PERL| PHP| PYTHON| RUBY
Last modified: March 30, 2006 @ 7:04 MST
Copyright (C) 1996-2017 Selene Scriven