[code-quality] Variable declarations + pyflakes

Peter Ludemann pludemann at google.com
Mon May 27 20:58:24 CEST 2013


Wouldn't static type-inferencing of Python give the same benefits, without
forcing programmers to write "Java-like" declarations?
Type inferencing would catch potential uninitialized variables, calling
non-existent methods, etc. ... and combined with a tool like lib2to3 could
be used to automatically insert type annotations into the code.



On 27 May 2013 06:09, Raphael Clifford <drraph at gmail.com> wrote:

> The email below was sent before it was finished.
>
>      var foo = 15
>      [...]
>      var foo = 10
>
>  should return an error.
>
>
>    foo = 15
>
> should return an error if foo was not declared before.
>
> The second answer of
>
> http://programmers.stackexchange.com/questions/15468/what-are-the-drawbacks-of-python
>  (with 60 votes) has some more details of a very similar suggestion.
>
> Is it possible for use pyflakes with some suitably defined annotation
> to do something equivalent? Getting python devs to accept the
> suggestion for the core python language more not be at all plausible.
>
> Raphael
>
>
>
> On 27 May 2013 14:05, Raphael Clifford <drraph at gmail.com> wrote:
> > I have recently been talking to friends/colleagues about their reasons
> > for not using python for large projects (say from a thousand lines of
> > code and with at least three people contributing). One of the problems
> > that comes up time and again is the difficulty in debugging python
> > code and in particular the simple sounding job of catching typos.  One
> > specific suggestion is the following.
> >
> > Make variable declaration compulsory.   For example.
> >
> >     var foo = 15
> >     [...]
> >     var foo = 10
> >
> > should return an error.
> >
> >
> > Similarly
> _______________________________________________
> code-quality mailing list
> code-quality at python.org
> http://mail.python.org/mailman/listinfo/code-quality
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/code-quality/attachments/20130527/7bc076a1/attachment.html>


More information about the code-quality mailing list