My python annoyances so far
steve at REMOVE.THIS.cybersource.com.au
Fri Apr 27 01:40:35 CEST 2007
On Thu, 26 Apr 2007 10:45:22 -0700, Steven Howe wrote:
> flifus at gmail.com wrote:
>>> Well, why do some things in the library have to be functions, and
>>> other things have to be class methods?
> Perhaps because some things are more naturally function like? For
> 'instance' (pardon the pun), functions shouldn't retain data. They
> perform an operation, return data and quit.
Why ever not? How the function performs the operation is an implementation
detail you shouldn't care about. Functions that cache the result of long
time-consuming complications are _good_.
You might also consider generators and iterators and co-routines. None of
those could exist if functions couldn't store data.
> Another example are with respect to 'int' and 'float' operations. Why
> should int(x) be a class?
That's a terrible example, because in fact int and float _are_ classes
(actually types, which are conceptually the same as classes but
More information about the Python-list