[Tutor] TypeError: not enough arguments for format string

bob gailer bgailer at gmail.com
Wed Jul 2 20:32:27 CEST 2008


broek at cc.umanitoba.ca wrote:
> [snip]

>
> In a case like
>
>>>> print '%s%s' %42 , 333
> ...
> TypeError: not enough arguments for format string
>
> it would be ambiguous whether 333 was intended as a second formatting 
> argument or as a second thing to be printed.

Here's where the Language Reference comes in handy:
 
print_stmt ::= "print" ( [expression ("," expression)* [","]]
expression_list ::= expression ( "," expression )* [","] # An expression 
list containing at least one comma yields a tuple

Given that, there is no ambiguity in print '%s%s' %42 , 333

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



More information about the Tutor mailing list