On 2021-05-24, Alan Gauld <alan.ga...@yahoo.co.uk> wrote: > On 24/05/2021 16:54, Michael F. Stemper wrote: > >> In my early days of writing python, I created lists named "list", >> dictionaries named "dict", and strings named "str". I mostly know better >> now, but sometimes still need to restrain my fingers. > > I think most newbie programmers make that mistake. I certainly > did when learning Pascal back in the 80's. > > But I was lucky, the tutorials were run by a guy who penalized > bad variable names severely and took a half-mark off for every > bad name. We very quickly learned to choose names that were > descriptive of the purpose rather than the type.
Tricky when you're writing general utility functions. What would you call the argument to a function that returns, say, an upper-cased version of its input? (Pretending for a moment that Python didn't already have such a function built-in ;-) ) I mean, sure, you could call it "inputString" or something but that sort of thing gets annoyingly verbose very quickly. If you're using type annotations then "input: str" would be ok but if you're not then just "input" is overly opaque (not to mention shadowing a builtin). This is why it's good when languages have conventions like "types and classes start with an upper-case letter", so that you can do "string = String()" without problems... -- https://mail.python.org/mailman/listinfo/python-list