Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] % Problem

edited November 2014 in OpenSesame

Hi everyone,

I'm starting to lose it on this piece of code:

for i in range(12):
 self.experiment.images [i] = exp.get_file(u'uni%.png' %i)

Which results in the following error message:

   ValueError: unsupported format character 'p' (0x70) at index 5

I don't get why the '%' character is not recognised for its usual purpose. I know it's a proper way to use this character so I'm a bit confused. The "%" is supposed to be replaced by the value of "i" for each iteration.

I'm sure there a simple explanation but I can't figure it out. Does anyone know what's happening?


PS: Just in order to give more information: I'm at work, so I'm on a MacBook Pro OS 10.10


  • edited 12:04AM


    I think what you meant to write is this:

    for i in range(12):
     self.experiment.images [i] = exp.get_file(u'uni%s.png' %i)

    The "%" within the string is used to specify the datatype that you will feed in later. In your case no valid type is present.

    Hope this helps.


  • edited 12:04AM


    Damn! I knew I was missing something. Of course you have to specify the data type! Thanks so much, it works like a charm now!



Sign In or Register to comment.