On 10/12/2020 13:06, Paul Bryan wrote:
Thanks for the comprehensive response, dn!
I guess I'm influenced by data classes here, where the object's
attribute type hints are represented by class variable annotations.
I'm a great fan of them too - the saving of 'boilerplate code' does it
for
Thanks for the comprehensive response, dn!
I guess I'm influenced by data classes here, where the object's
attribute type hints are represented by class variable annotations.
On Thu, 2020-12-10 at 07:49 +1300, dn via Python-list wrote:
> On 09/12/2020 13:17, Paul Bryan wrote:
> > Would this be
On 09/12/2020 13:17, Paul Bryan wrote:
Would this be a reasonably correct way to annotate a property with a
type hint?
class Foo:
... bar: int
If we build a class with (only) the above two lines, Python's help
lookup offers the following documentation:
<<<
Help on Foo in module
Would this be a reasonably correct way to annotate a property with a
type hint?
>>> class Foo:
... bar: int
... @property
... def bar(self):
... return 1
...
>>> foo = Foo()
>>> import typing
>>> typing.get_type_hints(foo)
{'bar': }
I could also decorate the property method