in our code we use a such function to read memory: def memory_get(name='MIR', default_value=1): ''' Retourne une valeur par défaut si la mémoire NVS ne contient pas l'élément recherché ''' try: _value = pycom.nvs_get(name) except Exception: _value = None if _value is None: _value = default_value return _value I'm not sure if that is the python way, but maybe that can help you!