Paul Ganssle writes:

 > If you didn't already know what the square brackets did, how would
 > you try and find out?

First I'd look it up in Python Essential Reference (Hi, @dabeaz! it
won't be there, though ;-).  Then I'd go to the Language Reference for
"def" and "class".  And if that failed, then I'd go buy Barry Warsaw
lunch.

OK, not everybody has a personal relationship with senior core devs,
but is asking people to read the Language Reference really so bad?

 > An additional benefit is that I find some of these examples to be a bit 
 > visually cluttered with all the syntax:
 > 
 > def  func1[T](a:  T)  ->  T:  ...   # OK
 > class ClassA[S, T](Protocol): ... # OK

Looks like the boomer version (square*) of C++ template variables.  Of
course, people learn Python to escape from C++, so maybe that's not
persuasive.

* telling you how old I am without telling you how ooooold I am

 > Which would look less cluttered with a prefix clause:
 > 
 > @with type T def  func1(a:  T)  ->  T:  ...   # OK
 > @with type S @with type T class ClassA(Protocol): ... # OK

For me, that's absolutely awful from a readability standpoint.  Put
the "def" or "class" 10-20 characters in from the margin?

I guess "stacked" it's no less readable than any decorator, but I also
don't like overloading the well-defined decorator notation with magic.

@with type T
def  func1(a:  T)  ->  T:  ...   # OK

@with type S
@with type T
class ClassA(Protocol): ... # OK

A thought: would it be possible to actually make it a with statement?

with Typevar() as T:
    def func1(a: T) -> T

Of course there might have to be magic in Typevar, but it would be far
more palatable to me than giving unary @ two kinds of magic.

IMO YMMV of course.

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/UTVCFIZ4CM3362JANAOBPEGJUTAWKSCI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to