oTree Forum >

Reference to participant.vars error in creating_subsession

#1 by AlanS

Hello all,

The following is a stripped down version of my creating_subsession method:
************************************************************
def creating_session(subsession):
    session = subsession.session
    for player in subsession.get_players():
        participant = player.participant
        print('participant_id = ' + str(participant.vars['participant_id']))
***********************************************************************
        
This errors out with the following:
************************************************
Failed to create session: 'participant_id'
Traceback (most recent call last):
  File "c:\users\alans\appdata\local\programs\python\python39\lib\site-packages\otree\session.py", line 447, in create_session_traceback_wrapper
    return create_session(**kwargs)
  File "c:\users\alans\appdata\local\programs\python\python39\lib\site-packages\otree\session.py", line 418, in create_session
    func(subsession)
  File "C:\Users\alans\Documents\otree\ITQ\__init__.py", line 56, in creating_session
    print('participant_id = ' + str(participant.vars['participant_id']))
KeyError: 'participant_id'
***************************************************
The same print statement works in my live_method.  

Note: I've attached my settings.py

Thanks!

Write a reply

Set forum username