Changes
Page history
Update Patterns/definitions.py for static variables
authored
Dec 02, 2022
by
Paul Lovis Maximilian Trüstedt
Show whitespace changes
Inline
Side-by-side
Patterns/definitions.py-for-static-variables.md
0 → 100644
View page @
2af83dc4
A class is created for a certain type of static variable, holding values, that will be used regularly in the future.
```
python
class
MediaRegionality
(
enum
.
Enum
):
REGIONAL
=
"
Regionales Medium
"
NATIONAL
=
"
Überregionales Medium
"
```
Then the values can be used with a naming and a sort of classification attached to them, which increases readability.
```
python
media_regionality
=
{
"
altmark zeitung
"
:
MediaRegionality
.
REGIONAL
,
"
antenne brandenburg
"
:
MediaRegionality
.
REGIONAL
,
"
apotheken-umschau.de
"
:
MediaRegionality
.
NATIONAL
,
[...]
}
```
This also allows to change the values for every usage by changing only the static variable at creation, instead of all usages one by one.
\ No newline at end of file