Here is the my code in python 3.6
class A(object)
def __init__(self, a: str):
self._int_a: int = int(a) # desired composition
def get_int_a(self) -> int:
return self._int_a
I want to rewrite this code in python 3.7
, how can i initialize self._int_a: int = int(a)
with dataclasses
module?
I know that i can do something like that but i can't get how to initialize _a: int = int(a)
or similar to that.
from dataclasses import dataclass
@dataclass
class A(object):
_a: int = int(a) # i want to get initialized `int` object here
def get_int_a(self) -> int:
return self._a
Thanks in advance for your ideas and suggestions.