[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484

Pavol Lisy pavol.lisy at gmail.com
Thu Aug 4 03:16:13 EDT 2016


On 8/4/16, Guido van Rossum <guido at python.org> wrote:
> On Wed, Aug 3, 2016 at 3:02 PM, Pavol Lisy <pavol.lisy at gmail.com> wrote:

>> def fnc():
>>   global a: list
>
> I'm not proposing to add such syntax, and the right place for the type
> of a would be at the global level, not on the `global` syatement.
>
>> a = 7
>> fnc()
>> a = [1, 2, 3]  # and this could be interesting for static type-checker
>> too
>
> Indeed, but that's not what we're debating here.

Sorry but for me is really important where we are going (at least as
inspiration).

As I understand now this changes could end in code which could be pure
python and on other hand also compilable by static typed compiler too.
Maybe it is what we wanted (I prefer this one), maybe we doesnt care
and maybe we want to avoid it.

For example Cython's code:
  cdef int n

could be writen:
  n: cdef.int

or
  n: 'cdef int'

and I think it could be good to see convergence here.

And maybe this
    cdef int n, k, i

could be inspiring too allow one to many possibility
  n, j, k: int   # (1)

I think it is natural and better than
  n, j, k: int, int, int

But (1)  would be discordant with this (from PEP484)
  def __init__(self, left: Node, right: Node)


More information about the Python-ideas mailing list