Python's idiom for function overloads

F. Petitjean littlejohn.75 at news.free.fr
Tue Feb 1 07:08:15 EST 2005


Le Tue, 01 Feb 2005 12:10:47 +0100, Philippe Fremy a écrit :
> 
>> Frequently, in Python, code which checks for types, rather than
>> checking for features, ends up being excessively restrictive and
>> insufficiently general.
> 
snip
> 
> Enforcing types also brings the benefit that the program is more 
> deterministic. In my experience, there is a lot more benefits to have an 
> object whose type is clearly identified than to have function that 
> accepts generic objects.
If you insist to always have only clearly identified types of variables
you will use the Hungarian notation :
bool bIsDir = blah
const char *lpszMessage = "It's a directory";
> 
> I would go as far as saying that variables should have immutable types. 
> It is more restricting that what python provides currently, but leads to 
> clearer programming practice: the intent of the developer shows up in 
> the type he uses.
clearer programming practice which goes with unreadable code ?
> 
> 
> While Python's dynamic typing liberty is enjoyable, I think it harms 
> when you start to work on big projects. It prevents you to put many 
> safety assumptions which might bite you back.
Python is strongly typed (at run-time). You can get a traceback sure but
it is rather difficult to get unreliable results.
> 
> 	regards,
> 
> 	Philippe



More information about the Python-list mailing list