[Python-ideas] Add annotations to global statement
Mike Graham
mikegraham at gmail.com
Thu Sep 6 15:26:16 CEST 2012
On Thu, Sep 6, 2012 at 8:30 AM, Alexandre Bosc <Athelopuce at gmx.fr> 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)
I cannot think of a case where having this feature would be of real
help making a well-designed Python program.
On Thu, Sep 6, 2012 at 9:17 AM, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
> 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
I believe the suggestion is that the expression becomes metadata
associated with the name var. Are you familiar with function
annotations, with which the parallel was drawn?
http://www.python.org/dev/peps/pep-3107/
Mike
More information about the Python-ideas
mailing list