Re: Struggling with basics



Jason wrote:

> My first problem (lack of understanding of course) is that if I run the
> above, I get an error saying:
>
> print "%s - %s" % name,score
> TypeError: not enough arguments for format string
>
> Now I understand what it's saying, but I don't understand why.
>

The problem is precedence.

print "%s - %s" % name,score

is equivalent to:

print ("%s - %s" % name),score

not:

print "%s - %s" % (name,score)

The % operator binds more tightly than the comma, so you need to put
parentheses around the argument to % (as in the last line above).
.



Relevant Pages

  • Re: Struggling with basics
    ... > def addScore: ... > My first problem is that if I run the ... I get an error saying: ... > Apologies for going over old ground and if I'm not understanding, ...
    (comp.lang.python)
  • Re: building for WinCE using EVC++ 3.0
    ... >the first problem is when i do an nmake, i get an error saying it can tfind ...
    (microsoft.public.windowsce.embedded.vc)
  • building openSSL for pocketpc2002
    ... i am trying to build OpenSSL for pocket pc 2002 using EVC++ 3.0 ... the first problem is when i do an nmake, i get an error saying it can tfind ...
    (microsoft.public.pocketpc.developer)
  • building for WinCE using EVC++ 3.0
    ... i am trying to build OpenSSL for pocket pc 2002 using EVC++ 3.0 ... the first problem is when i do an nmake, i get an error saying it can tfind ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Confusion with calling function of a subclass
    ... TREE.gettree# I get an error saying # TypeError: unbound method gettree() must be called ... # with TREE instance as first argument (got nothing instead ...
    (comp.lang.python)