[Python-ideas] No implicit variable declarations

Ryan rymg19 at gmail.com
Sat Apr 12 20:06:01 CEST 2014


Isn't this what MyPy is for?

James Nelson <retrobanana.jn at gmail.com> wrote:
>There are several problems with Python's implicit variable declaration.
>Just one tiny mistake, like assigning to SpamEggs instead of spamEggs
>will
>create a new variable SpamEggs, and spamEggs will hold a stale value.
>
>Two statements should be added to Python: (1) a statement that
>specifies
>that implicit declaration by assignment should be disabled, like
>Fortran's
>"implicit none", and (2) a variable declaration statement, a la "var
>spamEggs". Trying to assign to a non-existent variable would, of
>course,
>cause an error. If the non-existent variable's name is close enough to
>an
>existing variable's name, the interpreter might suggest the correct
>name:
>"Did you mean "spamEggs"?".
>
>This idea could even open Python to static typed variables, declared
>like
>"var spamEggs as int". This would prevent the stupid but very possible
>error of assigning "clientName" (a string) to "doorStatus" (a boolean).
>
>-rb
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>https://mail.python.org/mailman/listinfo/python-ideas
>Code of Conduct: http://python.org/psf/codeofconduct/

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140412/1b0d4b0f/attachment.html>


More information about the Python-ideas mailing list