[Python-ideas] keywording prohibited

spir denis.spir at free.fr
Sun May 3 11:36:17 CEST 2009


Le Sun, 3 May 2009 17:03:48 +1000,
Steven D'Aprano <steve at pearwood.info> s'exprima ainsi:

> e.g. instead of naming a variable "seq" or "list_", I'd have the name
> > specify what it's a list *of*.)  
> 
> Well, this is Python, and we use duck-typing, so everything would need 
> to be list_of_string_like_instances or similar :)
> 
> But seriously, I tend to use plurals for that. If I have an argument 
> that takes a collection of widgets, say, I call it "widgets", and write 
> code like this:
> 
> for widget in widgets:
>     whatever()

I use exactly the same convention.
And 100% agree with the fact that the Good Way is to use specific names that denote what use you have for the value, ie the concept the name carries /in your prog/.
But precisely sometimes the meaning is generic. Or so obvious from the context or application that it really looks stupid to over-specify (while I often do it anyway). Also, humans are lazy. [One may require a python programmer not to be lazy, but it will not buy much, and we still have to cope with the fact -- including for ourselves.]

In fact, I think issues about reusing builtin name are similar to the ones when bad-naming in general, including the fact that the developper is the first one trapped. But the consequences are potentially much worse and difficulty of debugging usually very great. 

Denis
------
la vita e estrany



More information about the Python-ideas mailing list