▲ 23 ▼ PEP: Is initializing typed variable with None bad practice? (lemmy.world) submitted 7 months ago by AstroLightz@lemmy.world to c/python@programming.dev 27 comments fedilink hide all child comments For example: class FooBar: def __init__(self): self.a: int = None self.foo: str = None Is this bad practice/go against PEP guidelines or is it fine?
[–] sbv@sh.itjust.works 3 points 7 months ago (1 child) Why not require values in the constructor? permalink fedilink source hideshow 1 child comment replies: [–] AstroLightz@lemmy.world [S] 2 points 7 months ago This is an example. For my actual use case, they would be private vars that would be set by class functions instead of passed to the constructor. permalink fedilink source parent
[–] AstroLightz@lemmy.world [S] 2 points 7 months ago This is an example. For my actual use case, they would be private vars that would be set by class functions instead of passed to the constructor. permalink fedilink source parent