Commits

Jason R. Coombs committed 05f98b0

Updated bug to include fix in Python 3.2

Comments (0)

Files changed (1)

bugs/string-formatter.py

 		return name + ' ' + str(random.randint(1,10))
 
 print("%(foo)s" % MyDynamicObject()) # works!
-print("{foo}".format(**MyDynamicObject()))
-# can't do that because MyDynamicObject can't enumerate every possible
-#  kwparam
-# fails with TypeError: format() argument after ** must be a mapping,
-#  not instance.
+if hasattr('', 'format_map'):
+	print("{foo}".format_map(MyDynamicObject())) # works on Python 3.2+
+else:
+	print("{foo}".format(**MyDynamicObject()))
+	# can't do that because MyDynamicObject can't enumerate every possible
+	#  kwparam
+	# fails with TypeError: format() argument after ** must be a mapping,
+	#  not instance.