[issue28861] Type Hints Syntax

2016-12-03 Thread YoSTEALTH

New submission from YoSTEALTH:

Type Hints Syntax
-

Goal: Is to make it easy to read function/methods arguments, yet keep the new 
and cool Type Hints.

For example this is a code from one of my function. Its getting to that point 
of what the heck is going on here?

def find_replace(string: str, find: (str, dict, list, tuple, set), replace: 
(str, list, tuple, set)='') -> str:
pass

I know it can be rewritten as:

T = (str, dict, list, tuple, set)
def find_replace(string: str, find: T, replace: T='') -> str:
pass

But when you start using variable to represent another variables type... maybe 
we are losing the plot here!

What if we could have both? Readability and type reference, what if it could be 
written as:

def find_replace(string, find, replace):
targ str, *(str, dict, list, tuple, set) -> str
# code here ...

targ = type argument (like *args and **kwargs)

Calling a "targ" like we call "global" but to represent types.

Simple Examples:

def Redirect(url='', code=301):
targ (str, int) -> None


Just think about it...

--
messages: 282304
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: Type Hints Syntax
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28861] Type Hints Syntax

2016-12-03 Thread YoSTEALTH

YoSTEALTH added the comment:

I was told to post this in python-ideas and also i totally missed the most 
important part (type aliases) in my example (rushed it)

--
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com