In PHP, we can use a PHP script to only return values, which is very useful for creating configuration files for an application.
Example DB.php
return array(
'host' => 'localhost',
'username' => 'username',
...
);
index.php
$config = include 'DB.php';
print_r($config);
// Retorna o array contendo os valores retornados em "DB.php"
When trying to "imitate" this in Python
, I was not successful, because it caused me an error.
Example db.py
return [
1, 2, 3
]
Result:
'return' outside function
In this case, if I wanted to load a file into python
, just for data-return purposes for configuration, how could I do it?