[Python-ideas] Welcome to the "Python-ideas" mailing list
Guido van Rossum
guido at python.org
Fri Apr 15 13:03:53 EDT 2016
Thanks for the positive tone of your message.
I do think there's some benefit in having a naming convention that's
consistent within your own code base -- especially if you're working with a
team and you can agree on a convention before you have written much code.
Joel Spolsky agrees: http://www.joelonsoftware.com/articles/Wrong.html
On Fri, Apr 15, 2016 at 9:57 AM, Richard Prosser <richard.prosser at mail.com>
> Is there any mileage in having a naming convention to indicate the type of
> a variable? I have never really liked the fact that the Python 'duck
> typing' policy is so lax, yet the new "Type Hints" package for Python 3 is
> rather clumsy, IMO.
> For example:
> github_response = requests.get('https://api.github.com/user', auth=('user', 'pass'))
> # Derived from http://docs.python-requests.org/en/master.
> The above request returns a Response
> <http://docs.python-requests.org/en/master/api/#requests.Response> object
> and so the variable has 'response' in its name.
> word_count = total_words_in_file('text_file')
> where 'count' has been defined (in the IDE, by the user perhaps) as an
> Integer and the function is known to return an Integer, perhaps via a local
> 'count' or 'total' variable.
> I know that this has been attempted before but I think that an IDE like
> PyCharm could actually check variable usage and issue a warning if a
> conflict is detected. Also earlier usages of this 'Hungarian Notation' have
> largely been applied to compiled languages - rather strangely, in the case
> of known types - rather than an interpreted one like Python.
> Please note that I have shown suffixes above but prefixes could also be
> valid. I am not sure about relying on 'type strings' *within* a variable
> name however.
> Is this idea feasible, do you think?
> Thanks ...
> PS Originally posted in
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas