Question: working with configurations in Spring Boot 2.1, I am circling around the question of how to implement a proper configuration management, where I have both parameters from a properties file and hardcoded values als configuration parameters, as well as default values for each parameter. Finally, I would need to have some sort of "integrity check" for each parameter, e.g. checking if an integer is in a specified range.

While this seems easy and simple enough, the realization for this is quite bloated and counterintuitive.

My minimal example looks like this:

application.yml

```
param1=42

```

Config.java

```
@Configuration
@PropertySource("classpath:application.yml")
public class Config {
    private static final int DEFAULT_PARAM1 = 1;
    private static final int PARAM1_MIN = 1;
    private static final int PARAM1_MAX = 5;

    @Autowired
    private int param1;

    public int getParam1() {
        return param1;
    }

    @PostConstruct
    public void init() {
        if(param1 == null || !checkParam1(param1)) param1 = DEFAULT_PARAM1;
    }

    public boolean checkParam1(param)
    {
        if(param > PARAM1_MIN || param < PARAM1_MAX)
            return true;
        else return false;
    }

    public void set setParam1(int param) {
        if(checkParam1(param))
            param1 = param;
    }
}

```

Now this seems to be an awful lot of code to simply set ONE parameter. Is there a more elegant, slim, and lean way to do this?

Answer: 
If I understand you correctly, it would help to create a dict from the list.  

You can use this dict comprehension statement.

```
h = [2.3, 1.4, 4.5, 4.5, 1.4, 2.3]

result = {f"L{index+1}": value for index, value in enumerate(h)}

> {'L1': 2.3, 'L2': 1.4, 'L3': 4.5, 'L4': 4.5, 'L5': 1.4, 'L6': 2.3}

```

And you can get the number which you need by specifying the key. For example:

```
print(result["L1"])

> 2.3

```
I would suggest you stick with the list for storing data , and access it via `h[i]`

However , you can still have your wish using exec:

```
for i,x in enumerate(h):
    exec(f'L{i}=x')

```

Please note that the first L will be L0 , change the above code if you want to start with 1.