Howdy, Stranger!

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

Supported by

Can't append str to lst after upgrading to OpenSesame v4

Hi mods,

Hopefully only a silly/quick question but I'm stumped - in some code that worked in v3, I split up sentences and iteratively append the words to an empty list called var.stimuli so that they are presented to participants one at a time (RSVP for EEG experiment; code snippet below). After upgrading OpenSesame to v4, I now get the error AttributeError: 'str' object has no attribute 'append'. I have confirmed that var.stimlui is a list and the word to append is a string, and it works to do this manually in the console, but for some reason returns the error when I run the inline script. Are lists and strings somehow handled differently in the new OpenSesame? The only clue is that when I print the word from the loop (w below), the output is e.g. the instead of 'the' (i.e. no quotes around it). Is that odd, even if it type() returns str?

Many thanks, Kate

# list to store words
var.stimuli = []

# function to split up sentences into words
def stim_prep(stims, trigger = "n"):
    stims = stims.split()
    for i, w in enumerate(stims):
        if(trigger == "y"):
            send = i + (var.cond + 1) * 10
        else:
            send = 0
        print(w)
        print(type(w))
        print(stimuli)
        print(type(stimuli))
        var.stimuli.append(w) # <--- error occurs here
        print(stimuli)
        word_canvas = canvas()
        word_canvas.text(w)
        word_canvas_list.append(word_canvas)
        var.pres_dur.append(pres_dur(w))
        var.trigger.append(send)
    return;

Comments

  • Update: It's something to do with using var.stimuli versus stimuli in the stim_prep function. If I use stimuli , it works fine, but then obviously it's not logged in the log file, which I would like. But it doesn't seem to recognise the pre-defined var.stimuli .

    I've attached the whole experiment in case it's helpful. stim_prep is in the "settings" inline script and var.stimuli is defined in the RSVP/prepare inline script (I tried moving everything to the RSVP/prepare script and the same problem happened).


  • Hi Kate,

    I think this has to do with this change in OS4: https://osdoc.cogsci.nl/4.0/notes/400/#important-backwards-incompatible-changes

    So, a list is not stored as a list anymore. To still include it in the logger, you can explicitly add it to the logger.

    Alternatively, it might work for you to not store the stimuli in a list but in a string, where each item is separated by the same character, so that during the analysis you can easily re-generate the list.

    For example:

    # during the experiment
    a_list = ['these', 'are', 'my', 'stimuli']
    a_string = '-'.join(a_list)
    # during the analysis
    a_string = read_from_logfile()
    a_list = a_string.split('-')
    

    Hope this helps,

    Eduard

    Buy Me A Coffee

  • Hi Eduard,

    Thanks very much for this, it makes a lot of sense and will work!

    Best,

    Kate

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