But then you'll have a list (I know it's a small list) in two places. You may not have to update it, but you might and forget about the second place.
For me, I'd do something like this:
(You can put it in a singleton and call it from anywhere etc etc)
var layer = 
for i in range(1, 21):
layer.append(ProjectSettings.get_setting("layer_names/2d_physics/layer_" + str(i)))
So that will printout: