How do I define a datetime field in a python dataclass?
Question:
trying to get the syntax of the Python 3.7 new dataclass right.
if I want to include a datetime value in my dataclass,
import datetime
from dataclasses import dataclass
@dataclass
class MyExampleWithDateTime:
mystring: str
myint: int
mydatetime: ???
What should I write for ??? for a datetime field?
Answers:
Like this:
@dataclass
class MyExampleWithDateTime:
mystring: str
myint: int
mydatetime: datetime.datetime
trying to get the syntax of the Python 3.7 new dataclass right.
if I want to include a datetime value in my dataclass,
import datetime
from dataclasses import dataclass
@dataclass
class MyExampleWithDateTime:
mystring: str
myint: int
mydatetime: ???
What should I write for ??? for a datetime field?
Like this:
@dataclass
class MyExampleWithDateTime:
mystring: str
myint: int
mydatetime: datetime.datetime