osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

naming methods in python (std lib)


On Sat, 30 Jun 2018 15:27:35 +0400, Abdur-Rahmaan Janhangeer wrote:

> normally, naming methods in python is given by
> 
> method_name
> 
> but i see some cases where this is not followed in the std lib
> 
> ex :  dict.fromkeys
> 
> should it not have been
> 
> from_keys?

Python is about 25 years old (1993 I think it was first released) and not 
all the names follow the same convention.

Sometimes that's because the names pre-date the convention. Sometimes its 
because the name follows some other convention, e.g. most of the "is" 
names look like isinstance, issubclass, string.islower etc rather than 
is_instance, is_subclass, is_lower.


-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson