[Python-ideas] Add annotations to global statement
Alexandre Bosc
Athelopuce at gmx.fr
Thu Sep 6 15:29:57 CEST 2012
Le 06. 09. 12 15:17, Rob Cliffe a écrit :
>
> On 06/09/2012 13:30, Alexandre Bosc wrote:
>> I think the annotations of parameters and return value of a function,
>> a useful practice for the user of the function.
>> As a function can modify or create global variables, and as it's
>> important for the end user, I would appreciate to add annotations
>> in the global statement.
>>
>> An annotation syntax similar to that of parameters could be employed :
>>
>> global var : expression
>> global var1 : expression1, var2 : expression2,...
>>
>>
>> cheers,
>>
>> Alex (geoscience modeler)
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> http://mail.python.org/mailman/listinfo/python-ideas
>>
>>
> Just to clarify:
>
> Are you proposing that
> global var : expression
> is equivalent to
> global var
> var = expression
> ?
>
> If so, wouldn't the syntax
> global var = expression
> be more readable?
> Rob Cliffe
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
Hi Rob,
No what I propose is :
def f(...):
global var: expression
....
is equivalent to
def f(...):
...
f.__annotations__['var']=expression
is it clear ?
Alex,
More information about the Python-ideas
mailing list