Type hinting of Python is just a toy ?

Chris Angelico rosuav at gmail.com
Fri Jan 4 03:55:23 EST 2019


On Fri, Jan 4, 2019 at 7:54 PM Ian Kelly <ian.g.kelly at gmail.com> wrote:
>
> On Fri, Jan 4, 2019 at 1:20 AM Chris Angelico <rosuav at gmail.com> wrote:
> > > Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language
> > > Python: Tuple(id: int, name: string, age: int)
> > > Other: class someClass {
> > >         public int id;
> > >         public string name;
> > >         public int age;
> > > }
> >
> > In other words, you want typing to be as restrictive as it is in C++
> > or Java. How would you define the type "JSON-encodable"? You can
> > encode a string, an integer, a float, an array of JSON-encodable
> > objects, and a mapping from strings to JSON-encodable objects. Can you
> > represent that as a class?
>
> I'm not sure the OP is saying that at all. It kind of sounds like he
> thinks that tuples are Python's version of classes, which is pretty
> hilarious.

Ohhhh. And here I thought that *closures* were Python's version of C++
classes. My bad.

ChrisA



More information about the Python-list mailing list