[closed] Python code
I have this code to generate a random ID and it seems to work:
import uuid
print uuid.uuid4().hex[:16].upper()
How do I write the result from the inline script to the logger? The result only prints on the prepare page, not the run page and when I run the code, the experiment goes straight to my "Welcome screen". My python inline script is before the Welcome Screen.
I also need to input the experiment code so can I code an input in the same inline script and output both the experiment code (which stays the same for each experiment) and the unique participant code.
Comments
Hi,
You have to capture the output of the function in a variable:
I'm not sure whether I understand. If you have a unique experiment code that doesn't change across participants, then you can just set it in the beginning of your script, e.g.
Or did you mean anything else?
Does that all make sense?
Eduard
Hey Eduard (and Happy New Year),
I think the problem is that I don't know exactly what the logger captures. And part of that problem is that the variables are difficult to see in the sidebar or topbar. Is there a way to print these out or copy them to an excel file?
Thanks for added information to the inline script. I thought it might be that but I wasn't sure because of my logger confusion.
Hi, printing them out is very easy. In the code of my previous code I have a line that starts with
printthat will print it to the debug window (activate it with ctrl+D). If you run your experiment, you can check the logfile that is written to look at the variables. But that only works after testing your experiment, not online.Eduard
This all works in the new version too. Thanks for your help. This discussion can be closed.
Is there a place we can put out closed discussions so I know which ones are still active?
Generally, we don't close discussions, because maybe some other person will have a closely related question at some point in the future. If nobody is posting into discussion, they will just sink down the list.
But the discussion stays in "My Discussions" so I was wondering if there was a way to clear out the ones that have been resolved?
I don't think that can be changed. Sorry.
Hey, maybe there can be like a message on it like the other messages that show up or maybe an icon - that would be helpful
Hey, you did that! Great! This one can be closed too. Thanks so much!