回答編集履歴
1
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
`file_path`を返す**関数
|
1
|
+
`file_path`を返す**関数を@propertyで装飾**すればよいかと思います。
|
2
2
|
```Pytnon
|
3
3
|
from dataclasses import dataclass
|
4
4
|
from pathlib import Path
|
@@ -7,6 +7,7 @@
|
|
7
7
|
class BaseConfig():
|
8
8
|
save_directory = 'default'
|
9
9
|
|
10
|
+
@property
|
10
11
|
def file_path(self):
|
11
12
|
return Path(self.save_directory, 'result.txt')
|
12
13
|
|
@@ -15,7 +16,7 @@
|
|
15
16
|
|
16
17
|
for c in [BaseConfig(), TestConfig()]:
|
17
18
|
print(c.save_directory)
|
18
|
-
print(c.file_path
|
19
|
+
print(c.file_path)
|
19
20
|
|
20
21
|
"""
|
21
22
|
default
|
@@ -23,4 +24,5 @@
|
|
23
24
|
test
|
24
25
|
test\result.txt
|
25
26
|
"""
|
27
|
+
```
|
26
28
|
|