Howdy, Stranger!

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

Supported by

[closed] Python code

edited January 2018 in OpenSesame

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:

    import uuid
    var.ID =  uuid.uuid4().hex[:16].upper() # save the code
    print var.ID # print the code
    

    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.

    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.

    import uuid
    var.ID =  uuid.uuid4().hex[:16].upper() # save the code
    print var.ID # print the code
    # set experiment code
    var.experimentCode = 10 # or whatever you want the code to be
    

    Or did you mean anything else?

    Does that all make sense?

    Eduard

    Buy Me A Coffee

  • 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 print that 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

    Buy Me A Coffee

  • 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.

    Buy Me A Coffee

  • 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.

    Buy Me A Coffee

  • 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!

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games