File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 66
66
print (">%-+08.4d<" % - 12 )
67
67
print (">%-+08.4d<" % 12 )
68
68
69
+ # Should be able to print dicts; in this case they aren't used
70
+ # to lookup keywords in formats like %(foo)s
71
+ print ('%s' % {})
72
+ print ('%s' % ({},))
73
+
69
74
# Cases when "*" used and there's not enough values total
70
75
try :
71
76
print ("%*s" % 5 )
77
82
print ("TypeError" )
78
83
79
84
print ("%(foo)s" % {"foo" : "bar" , "baz" : False })
85
+ print ("%s %(foo)s %(foo)s" % {"foo" : 1 })
80
86
try :
81
87
print ("%(foo)s" % {})
82
88
except KeyError :
87
93
except TypeError :
88
94
print ("TypeError" )
89
95
96
+ # When using %(foo)s format the single argument must be a dict
97
+ try :
98
+ '%(foo)s' % 1
99
+ except TypeError :
100
+ print ('TypeError' )
101
+ try :
102
+ '%(foo)s' % ({},)
103
+ except TypeError :
104
+ print ('TypeError' )
105
+
90
106
try :
91
107
'%(a' % {'a' :1 }
92
108
except ValueError :
You can’t perform that action at this time.
0 commit comments